{"name":"leven","version":"4.1.0","description":"Measure the difference between two strings using the Levenshtein distance algorithm","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/leven.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava","bench":"node bench.js"},"keywords":["leven","levenshtein","distance","algorithm","string","difference","diff","fast","fuzzy","similar","similarity","compare","comparison","edit","text","match","matching"],"devDependencies":{"ava":"^3.15.0","fast-levenshtein":"^3.0.0","ld":"^0.1.0","levdist":"^2.2.10","levenshtein":"^1.0.5","levenshtein-component":"^0.0.1","levenshtein-edit-distance":"^3.0.0","natural":"^5.0.4","talisman":"^1.1.4","tinybench":"^4.0.1","xo":"^0.44.0"},"_id":"leven@4.1.0","gitHead":"235e7758c8ec95fc3a30ef32528ce1fa409c040a","bugs":{"url":"https://github.com/sindresorhus/leven/issues"},"homepage":"https://github.com/sindresorhus/leven#readme","_nodeVersion":"20.19.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-KZ9W9nWDT7rF7Dazg8xyLHGLrmpgq2nVNFUckhqdW3szVP6YhCpp/RAnpmVExA9JvrMynjwSLVrEj3AepHR6ew==","shasum":"1e37150e1711d18bb14e380a5c779995235a710e","tarball":"http://registry-npm.ywwl.com/leven/download/leven-4.1.0.tgz","fileCount":5,"unpackedSize":10206,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCwQpkSHbbPmLFTBEo4xk3ZfLICzhJv3FbdR+l6vsomZQIhAN9D624Zr971IZWF02A9kEi6eSC1N/A5C70AdVE3swSi"}],"size":3724,"noattachment":false,"key":"/leven/-/leven-4.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/leven_4.1.0_1757593672111_0.10203871312336643"},"_hasShrinkwrap":false,"readme":"# leven\n\n> Measure the difference between two strings using the [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) algorithm\n\n## Install\n\n```sh\nnpm install leven\n```\n\n## Usage\n\n```js\nimport leven from 'leven';\n\nleven('cat', 'cow');\n//=> 2\n```\n\n## API\n\n### leven(first, second, options?)\n\n#### first\n\nType: `string`\n\nFirst string.\n\n#### second\n\nType: `string`\n\nSecond string.\n\n#### options\n\nType: `object`\n\n##### maxDistance\n\nType: `number`\n\nMaximum distance to calculate.\n\nIf the actual distance exceeds this value, the function will return `maxDistance` instead of the actual distance. This can significantly improve performance when you only care about matches within a certain threshold.\n\n```js\nimport leven from 'leven';\n\nleven('abcdef', '123456', {maxDistance: 3});\n//=> 3\n\nleven('cat', 'cow', {maxDistance: 5});\n//=> 2\n```\n\n### closestMatch(target, candidates, options?)\n\nFind the closest matching string from an array of candidates.\n\n#### target\n\nType: `string`\n\nThe string to find matches for.\n\n#### candidates\n\nType: `string[]`\n\nArray of candidate strings to search through.\n\n#### options\n\nType: `object`\n\nSame options as `leven()`.\n\n##### maxDistance\n\nType: `number`\n\nMaximum distance to consider. Candidates with a distance greater than this value will be ignored.\n\nReturns the closest matching string from candidates, or `undefined` if no candidates are provided or if no match is found within `maxDistance`.\n\n```js\nimport {closestMatch} from 'leven';\n\nclosestMatch('kitten', ['sitting', 'kitchen', 'mittens']);\n//=> 'kitchen'\n\nclosestMatch('hello', ['jello', 'yellow', 'bellow'], {maxDistance: 2});\n//=> 'jello'\n\n// No match within distance threshold\nclosestMatch('abcdef', ['123456', '1234567890'], {maxDistance: 2});\n//=> undefined\n```\n\n## Related\n\n- [leven-cli](https://github.com/sindresorhus/leven-cli) - CLI for this module\n","publish_time":1757593672301,"_cnpm_publish_time":1757593672301,"dist-tags":{"latest":"4.1.0"}}