diff --git a/node_modules/leven/index.d.ts b/node_modules/leven/index.d.ts new file mode 100644 index 0000000000000..571833ae44b7d --- /dev/null +++ b/node_modules/leven/index.d.ts @@ -0,0 +1,21 @@ +declare const leven: { + /** + Measure the difference between two strings. + + @example + ``` + import leven = require('leven'); + + leven('cat', 'cow'); + //=> 2 + ``` + */ + (left: string, right: string): number; + + // TODO: Remove this for the next major release, refactor the whole definition to: + // declare function leven(left: string, right: string): number; + // export = leven; + default: typeof leven; +}; + +export = leven; diff --git a/node_modules/leven/index.js b/node_modules/leven/index.js new file mode 100644 index 0000000000000..25f5a3d5c8bd4 --- /dev/null +++ b/node_modules/leven/index.js @@ -0,0 +1,77 @@ +'use strict'; +const array = []; +const charCodeCache = []; + +const leven = (left, right) => { + if (left === right) { + return 0; + } + + const swap = left; + + // Swapping the strings if `a` is longer than `b` so we know which one is the + // shortest & which one is the longest + if (left.length > right.length) { + left = right; + right = swap; + } + + let leftLength = left.length; + let rightLength = right.length; + + // Performing suffix trimming: + // We can linearly drop suffix common to both strings since they + // don't increase distance at all + // Note: `~-` is the bitwise way to perform a `- 1` operation + while (leftLength > 0 && (left.charCodeAt(~-leftLength) === right.charCodeAt(~-rightLength))) { + leftLength--; + rightLength--; + } + + // Performing prefix trimming + // We can linearly drop prefix common to both strings since they + // don't increase distance at all + let start = 0; + + while (start < leftLength && (left.charCodeAt(start) === right.charCodeAt(start))) { + start++; + } + + leftLength -= start; + rightLength -= start; + + if (leftLength === 0) { + return rightLength; + } + + let bCharCode; + let result; + let temp; + let temp2; + let i = 0; + let j = 0; + + while (i < leftLength) { + charCodeCache[i] = left.charCodeAt(start + i); + array[i] = ++i; + } + + while (j < rightLength) { + bCharCode = right.charCodeAt(start + j); + temp = j++; + result = j; + + for (i = 0; i < leftLength; i++) { + temp2 = bCharCode === charCodeCache[i] ? temp : temp + 1; + temp = array[i]; + // eslint-disable-next-line no-multi-assign + result = array[i] = temp > result ? temp2 > result ? result + 1 : temp2 : temp2 > temp ? temp + 1 : temp2; + } + } + + return result; +}; + +module.exports = leven; +// TODO: Remove this for the next major release +module.exports.default = leven; diff --git a/node_modules/leven/license b/node_modules/leven/license new file mode 100644 index 0000000000000..e7af2f77107d7 --- /dev/null +++ b/node_modules/leven/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/leven/package.json b/node_modules/leven/package.json new file mode 100644 index 0000000000000..e1b3d8ee0cb25 --- /dev/null +++ b/node_modules/leven/package.json @@ -0,0 +1,57 @@ +{ + "name": "leven", + "version": "3.1.0", + "description": "Measure the difference between two strings using the fastest JS implementation of the Levenshtein distance algorithm", + "license": "MIT", + "repository": "sindresorhus/leven", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=6" + }, + "scripts": { + "test": "xo && ava && tsd", + "bench": "matcha bench.js" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "leven", + "levenshtein", + "distance", + "algorithm", + "algo", + "string", + "difference", + "diff", + "fast", + "fuzzy", + "similar", + "similarity", + "compare", + "comparison", + "edit", + "text", + "match", + "matching" + ], + "devDependencies": { + "ava": "^1.4.1", + "fast-levenshtein": "^2.0.6", + "ld": "^0.1.0", + "levdist": "^2.2.9", + "levenshtein": "^1.0.5", + "levenshtein-component": "^0.0.1", + "levenshtein-edit-distance": "^2.0.3", + "matcha": "^0.7.0", + "natural": "^0.6.3", + "talisman": "^0.21.0", + "tsd": "^0.7.2", + "xo": "^0.24.0" + } +} diff --git a/node_modules/leven/readme.md b/node_modules/leven/readme.md new file mode 100644 index 0000000000000..33625c46f0059 --- /dev/null +++ b/node_modules/leven/readme.md @@ -0,0 +1,50 @@ +# leven [![Build Status](https://travis-ci.org/sindresorhus/leven.svg?branch=master)](https://travis-ci.org/sindresorhus/leven) + +> Measure the difference between two strings
+> One of the fastest JS implementations of the [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) algorithm + + +## Install + +``` +$ npm install leven +``` + + +## Usage + +```js +const leven = require('leven'); + +leven('cat', 'cow'); +//=> 2 +``` + + +## Benchmark + +``` +$ npm run bench +``` + +``` + 165,926 op/s » leven + 164,398 op/s » talisman + 1,044 op/s » levenshtein-edit-distance + 628 op/s » fast-levenshtein + 497 op/s » levenshtein-component + 195 op/s » ld + 190 op/s » levenshtein + 168 op/s » levdist + 10 op/s » natural +``` + + +## Related + +- [leven-cli](https://github.com/sindresorhus/leven-cli) - CLI for this module + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/meant/.github/workflows/ci.yml b/node_modules/meant/.github/workflows/ci.yml deleted file mode 100644 index b11451fa603d5..0000000000000 --- a/node_modules/meant/.github/workflows/ci.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Node.js CI - -on: [push, pull_request] - -jobs: - build: - strategy: - matrix: - node-version: [6.x, 8.x, 10.x, 12.x] - os: [ubuntu-latest, windows-latest, macOS-latest] - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm install - - run: npm test diff --git a/node_modules/meant/CHANGELOG.md b/node_modules/meant/CHANGELOG.md deleted file mode 100644 index 89b0e6f94e1cc..0000000000000 --- a/node_modules/meant/CHANGELOG.md +++ /dev/null @@ -1,37 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. - -### [1.0.2](https://github.com/watilde/meant/compare/v1.0.1...v1.0.2) (2020-07-19) - - -### Bug Fixes - -* **deps:** bump standard, standard-version and tap ([d31fb06](https://github.com/watilde/meant/commit/d31fb064495b031dd1152726da9bd2198daa36ff)) -* **deps:** patch update in lock file ([4e699ee](https://github.com/watilde/meant/commit/4e699ee8751a69923dddf18c940acce630f4bf29)) - - -## [1.0.1](https://github.com/watilde/meant/compare/v1.0.0...v1.0.1) (2017-08-23) - - -### Bug Fixes - -* **package:** tweak the line ([915d949](https://github.com/watilde/meant/commit/915d949)) - - - - -# 1.0.0 (2016-09-08) - - -### Bug Fixes - -* **deps:** install devDeps and update tests ([d766d6f](https://github.com/watilde/meant/commit/d766d6f)) -* **run-script:** add npm run release command ([9387904](https://github.com/watilde/meant/commit/9387904)) -* **test:** add test.js ([65b6e99](https://github.com/watilde/meant/commit/65b6e99)) -* **travis:** add .travis.yml ([24d918c](https://github.com/watilde/meant/commit/24d918c)) - - -### Features - -* **new-meant:** add index.js ([7289b99](https://github.com/watilde/meant/commit/7289b99)) diff --git a/node_modules/meant/LICENSE b/node_modules/meant/LICENSE deleted file mode 100644 index 4205f889a4b31..0000000000000 --- a/node_modules/meant/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2016 Daijirō Wachi - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/meant/README.md b/node_modules/meant/README.md deleted file mode 100644 index 2fe43b610a71d..0000000000000 --- a/node_modules/meant/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# meant ![Build status](https://github.com/watilde/meant/workflows/Node.js%20CI/badge.svg) - -Like the `Did you mean?` in git for npm - -## API -### meant(item, list) -+ item {String} A key for finding an approximate value -+ list {Array} A list for comparing with the item - -```js -const meant = require('meant') -const result = meant('foa', ['foo', 'bar', 'baz']) -// => [ 'foo' ] -``` - -## Installation - -Download node at [nodejs.org](http://nodejs.org) and install it, if you haven't already. - -```sh -npm install meant --save -``` - - -## Tests - -```sh -npm install -npm test -``` -``` - -> meant@1.0.0 test /Users/watilde/Development/meant -> standard && tap test.js -TAP version 13 -# Subtest: test.js - # Subtest: test vs ['tast', 'tbst', 'tcst', 'foo'] - ok 1 - list has tast - ok 2 - list has tbst - ok 3 - list has tcst - ok 4 - list doesn't have foo - 1..4 - ok 1 - test vs ['tast', 'tbst', 'tcst', 'foo'] # time=11.816ms - 1..1 - # time=44.006ms -ok 1 - test.js # time=249.154ms -1..1 -# time=267.371ms - -``` - -## Dependencies - -None - -## Dev Dependencies - -- [standard](https://github.com/feross/standard): JavaScript Standard Style -- [standard-version](https://github.com/conventional-changelog/standard-version): replacement for `npm version` with automatic CHANGELOG generation -- [tap](https://github.com/tapjs/node-tap): A Test-Anything-Protocol library - - -## License - -MIT - -_Generated by [package-json-to-readme](https://github.com/zeke/package-json-to-readme)_ diff --git a/node_modules/meant/index.js b/node_modules/meant/index.js deleted file mode 100644 index 647ba912d42ec..0000000000000 --- a/node_modules/meant/index.js +++ /dev/null @@ -1,49 +0,0 @@ -function levenshteinD (s1, s2) { - var d = [] - var i = 0 - - for (i = 0; i <= s1.length; i++) d[i] = [i] - for (i = 0; i <= s2.length; i++) d[0][i] = i - - s2.split('').forEach(function (c2, j) { - s1.split('').forEach(function (c1, i) { - if (c1 === c2) { - d[i + 1][j + 1] = d[i][j] - return - } - d[i + 1][j + 1] = Math.min( - d[i][j + 1] + 1, - d[i + 1][j] + 1, - d[i][j] + 1 - ) - }) - }) - - return d[s1.length][s2.length] -} - -function meant (scmd, commands) { - var d = [] - var bestSimilarity = [] - - commands.forEach(function (cmd, i) { - var item = {} - item[levenshteinD(scmd, cmd)] = i - d.push(item) - }) - - d.sort(function (a, b) { - return Number(Object.keys(a)[0]) - Number(Object.keys(b)[0]) - }) - - d.forEach(function (item) { - var key = Number(Object.keys(item)[0]) - if (scmd.length / 2 >= key) { - bestSimilarity.push(commands[item[key]]) - } - }) - - return bestSimilarity -} - -module.exports = meant diff --git a/node_modules/meant/package.json b/node_modules/meant/package.json deleted file mode 100644 index 4d92133550dfa..0000000000000 --- a/node_modules/meant/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "meant", - "version": "1.0.2", - "description": "Like the `Did you mean?` in git for npm", - "main": "index.js", - "devDependencies": { - "standard": "^11.0.1", - "standard-version": "^8.0.1", - "tap": "^12.7.0" - }, - "scripts": { - "test": "standard && tap test.js", - "release": "standard-version" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/watilde/meant.git" - }, - "keywords": [ - "meant" - ], - "author": "Daijiro Wachi", - "license": "MIT", - "bugs": { - "url": "https://github.com/watilde/meant/issues" - }, - "homepage": "https://github.com/watilde/meant#readme" -} diff --git a/node_modules/meant/test.js b/node_modules/meant/test.js deleted file mode 100644 index bc7ba564be9dd..0000000000000 --- a/node_modules/meant/test.js +++ /dev/null @@ -1,11 +0,0 @@ -var test = require('tap').test -var meant = require('./') - -test('test vs [\'tast\', \'tbst\', \'tcst\', \'foo\']', function (t) { - var list = meant('test', ['tast', 'tbst', 'tcst', 'foo']) - t.notEqual(list.indexOf('tast'), -1, 'list has tast') - t.notEqual(list.indexOf('tbst'), -1, 'list has tbst') - t.notEqual(list.indexOf('tcst'), -1, 'list has tcst') - t.equal(list.indexOf('foo'), -1, 'list doesn\'t have foo') - t.end() -}) diff --git a/package-lock.json b/package-lock.json index 72d2608116049..3d7eb54864925 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,6 +36,7 @@ "ini", "init-package-json", "is-cidr", + "leven", "libnpmaccess", "libnpmfund", "libnpmhook", @@ -47,7 +48,6 @@ "libnpmversion", "lockfile", "make-fetch-happen", - "meant", "mkdirp", "mkdirp-infer-owner", "ms", @@ -115,6 +115,7 @@ "ini": "^1.3.5", "init-package-json": "^1.10.3", "is-cidr": "^3.0.0", + "leven": "^3.1.0", "libnpmaccess": "^4.0.0", "libnpmfund": "0.0.0", "libnpmhook": "^6.0.0", @@ -126,7 +127,6 @@ "libnpmversion": "^1.0.3", "lockfile": "^1.0.4", "make-fetch-happen": "^8.0.9", - "meant": "~1.0.1", "mkdirp": "^1.0.4", "mkdirp-infer-owner": "^2.0.0", "ms": "^2.1.2", @@ -3668,6 +3668,15 @@ "lcov-parse": "bin/cli.js" } }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "inBundle": true, + "engines": { + "node": ">=6" + } + }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -4012,12 +4021,6 @@ "marked": "^0.6.2" } }, - "node_modules/meant": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/meant/-/meant-1.0.2.tgz", - "integrity": "sha512-KN+1uowN/NK+sT/Lzx7WSGIj2u+3xe5n2LbwObfjOhPZiA+cCfCm6idVl0RkEfjThkw5XJ96CyRcanq6GmKtUg==", - "inBundle": true - }, "node_modules/merge-source-map": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/merge-source-map/-/merge-source-map-1.1.0.tgz", @@ -11951,6 +11954,11 @@ "integrity": "sha1-6w1GtUER68VhrLTECO+TY73I9+A=", "dev": true }, + "leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==" + }, "levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -12218,11 +12226,6 @@ "dev": true, "requires": {} }, - "meant": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/meant/-/meant-1.0.2.tgz", - "integrity": "sha512-KN+1uowN/NK+sT/Lzx7WSGIj2u+3xe5n2LbwObfjOhPZiA+cCfCm6idVl0RkEfjThkw5XJ96CyRcanq6GmKtUg==" - }, "merge-source-map": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/merge-source-map/-/merge-source-map-1.1.0.tgz", diff --git a/package.json b/package.json index 058fcf7e08774..3f3a4a5840a46 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,6 @@ "libnpmteam": "^2.0.1", "libnpmversion": "^1.0.3", "lockfile": "^1.0.4", - "meant": "~1.0.1", "mkdirp": "^1.0.4", "mkdirp-infer-owner": "^2.0.0", "ms": "^2.1.2", @@ -117,7 +116,8 @@ "validate-npm-package-name": "~3.0.0", "which": "^2.0.2", "write-file-atomic": "^2.4.3", - "make-fetch-happen": "^8.0.9" + "make-fetch-happen": "^8.0.9", + "leven": "^3.1.0" }, "bundleDependencies": [ "@npmcli/arborist", @@ -148,6 +148,7 @@ "ini", "init-package-json", "is-cidr", + "leven", "libnpmaccess", "libnpmfund", "libnpmhook", @@ -159,7 +160,6 @@ "libnpmversion", "lockfile", "make-fetch-happen", - "meant", "mkdirp", "mkdirp-infer-owner", "ms",