fast-levenshtein - Levenshtein algorithm in Javascript
An efficient Javascript implementation of the Levenshtein algorithm with asynchronous callback support.
Features
Works in node.js and in the browser.
Better performance than other implementations by not needing to store the whole matrix (more info).
Provides synchronous and asynchronous versions of the algorithm.
Asynchronous version is almost as fast as the synchronous version for small strings and can also provide progress updates.
Comprehensive test suite and performance benchmark.
Small: <1 KB minified and gzipped
Installation
node.js
Install using npm:
Browser
Using bower:
If you are not using any module loader system then the API will then be accessible via the window.Levenshtein
object.
Examples
Synchronous
Asynchronous
Asynchronous with progress updates
Building and Testing
To build the code and run the tests:
Performance
Thanks to Titus Wormer for encouraging me to do this.
Benchmarked against other node.js levenshtein distance modules (on Macbook Air 2012, Core i7, 8GB RAM):
You can run this benchmark yourself by doing:
Contributing
If you wish to submit a pull request please update and/or create new tests for any changes you make and ensure the grunt build passes.
See CONTRIBUTING.md for details.
License
MIT - see LICENSE.md