githubEdit

fast-levenshtein - Levenshtein algorithm in Javascript

Build Statusarrow-up-right NPM modulearrow-up-right NPM downloadsarrow-up-right Follow on Twitterarrow-up-right

An efficient Javascript implementation of the Levenshtein algorithmarrow-up-right with locale-specific collator support.

Features

  • Works in node.js and in the browser.

  • Better performance than other implementations by not needing to store the whole matrix (more infoarrow-up-right).

  • Locale-sensitive string comparisions if needed.

  • Comprehensive test suite and performance benchmark.

  • Small: <1 KB minified and gzipped

Installation

node.js

Install using npmarrow-up-right:

$ npm install fast-levenshtein

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

Default usage

Locale-sensitive string comparisons

It supports using Intl.Collatorarrow-up-right for locale-sensitive string comparisons:

Building and Testing

To build the code and run the tests:

Performance

Thanks to Titus Wormerarrow-up-right for encouraging mearrow-up-right 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.mdarrow-up-right for details.

License

MIT - see LICENSE.mdarrow-up-right

Last updated