Note: if you need to take the edit distance of one string against many strings (maybe billions), I have created a GPU-implementation that will be atleast 1000x faster than this. Contact me, if you're interested.
$ npm install node-levenshtein --save
const levenshtein =// Print edit-distance between 'fast' and 'faster'console//=> 2// Print string from array with lowest edit-distance to 'fast'console//=> 'faster'
I generated 500 pairs of strings with length N. I measured the ops/sec each library achieves to process all the given pairs. Higher is better. node-levenshtein is a lot faster in all cases.
This image shows the relative performance between node-levenshtein and js-levenshtein (the 2nd fastest). As you can see, node-levenshtein is a lot faster for small strings, but especially for long strings (8x faster when N = 1024).
This project is licensed under the MIT License - see the LICENSE.md file for details