levenshtein-edit-distance
Levenshtein edit distance (by Vladimir Levenshtein). No cruft. Real fast.
Installation
NPM:
$ npm install levenshtein-edit-distance
Component.js:
$ component install wooorm/levenshtein-edit-distance
Usage
var levenshteinDistance = require('levenshtein-edit-distance');
levenshteinDistance('levenshtein', 'levenshtein');
levenshteinDistance('sitting', 'kitten');
levenshteinDistance('gumbo', 'gambol');
levenshteinDistance('saturday', 'sunday');
levenshteinDistance('DwAyNE', 'DUANE') !== levenshteinDistance('dwayne', 'DuAnE');
levenshteinDistance("aarrgh", "aargh") === levenshteinDistance("aargh", "aarrgh");
Other Levenshtein libraries
Benchmark
On a MacBook Air, it runs about 313,000 op/s, which is faster than the competition.
Run the benchmark yourself:
$ npm run install-benchmark
$ npm run benchmark
levenshtein-edit-distance — this module
313 op/s » op/s * 1,000
fast-levenshtein — “fast”... pff ;)
268 op/s » op/s * 1,000
natural — to be fair, it offers more options
213 op/s » op/s * 1,000
Levenshtein — to be fair, it lets you inspect a matrix
141 op/s » op/s * 1,000
License
MIT