Socket
Socket
Sign inDemoInstall

fast-levenshtein

Package Overview
Dependencies
1
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-levenshtein

Efficient implementation of Levenshtein algorithm with locale-specific collator support.


Version published
Maintainers
1
Weekly downloads
34,063,029
decreased by-7.83%

Weekly downloads

Package description

What is fast-levenshtein?

The fast-levenshtein npm package is a high-performance JavaScript implementation of the Levenshtein algorithm, which measures the difference between two sequences. It is commonly used to determine the similarity between two strings by calculating the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into the other.

What are fast-levenshtein's main functionalities?

Calculate Levenshtein distance

This feature allows you to calculate the Levenshtein distance between two strings. The code sample demonstrates how to use the package to find the distance between 'back' and 'book', which is 2.

const levenshtein = require('fast-levenshtein');
const distance = levenshtein.get('back', 'book');
console.log(distance); // Output: 2

Other packages similar to fast-levenshtein

Readme

Source

fast-levenshtein - Levenshtein algorithm in Javascript

Build Status NPM module NPM downloads Follow on Twitter

A Javascript implementation of the Levenshtein algorithm with locale-specific collator support. This uses fastest-levenshtein under the hood.

Features

  • Works in node.js and in the browser.
  • Locale-sensitive string comparisons if needed.
  • Comprehensive test suite.

Installation

$ npm install fast-levenshtein

CDN

The latest version is now also always available at https://npm-cdn.com/pkg/fast-levenshtein/

Examples

Default usage

var levenshtein = require('fast-levenshtein');

var distance = levenshtein.get('back', 'book');   // 2
var distance = levenshtein.get('我愛你', '我叫你');   // 1

Locale-sensitive string comparisons

It supports using Intl.Collator for locale-sensitive string comparisons:

var levenshtein = require('fast-levenshtein');

levenshtein.get('mikailovitch', 'Mikhaïlovitch', { useCollator: true});
// 1

Building and Testing

To build the code and run the tests:

$ npm install -g grunt-cli
$ npm install
$ npm run build

Performance

This uses fastest-levenshtein under the hood.

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

Keywords

FAQs

Last updated on 22 Jul 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc