levenshtein-edit-distance
Levenshtein edit distance (by Vladimir Levenshtein). No cruft. Real fast.
Installation
npm:
$ npm install levenshtein-edit-distance
Component:
$ component install wooorm/levenshtein-edit-distance
Bower:
$ bower install 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 1,915,000 op/s.
Run the benchmark yourself:
$ npm run benchmark
Levenshtein — to be fair, it lets you inspect a matrix
129 op/s » op/s * 1,000
natural — to be fair, it offers more options
212 op/s » op/s * 1,000
levenshtein-deltas
252 op/s » op/s * 1,000
levenshtein-component
335 op/s » op/s * 1,000
fast-levenshtein
1,251 op/s » op/s * 1,000
Leven — fast.
1,541 op/s » op/s * 1,000
levenshtein-edit-distance — this module
1,915 op/s » op/s * 1,000
License
MIT © Titus Wormer