Socket
Socket
Sign inDemoInstall

leven

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    leven

Measure the difference between two strings using the fastest JS implementation of the Levenshtein distance algorithm


Version published
Weekly downloads
24M
decreased by-2.92%
Maintainers
1
Install size
4.04 kB
Created
Weekly downloads
 

Package description

What is leven?

The leven npm package is a JavaScript library for measuring the difference between two strings. It uses the Levenshtein distance algorithm to calculate the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into the other. This can be particularly useful in applications that need to perform fuzzy matching, spell checking, or any scenario where determining how similar two strings are is necessary.

What are leven's main functionalities?

Calculate Levenshtein distance

This feature allows you to calculate the Levenshtein distance between two strings, which is the number of edits needed to transform one string into the other. The code sample demonstrates how to use the leven package to find the distance between 'kitten' and 'sitting', which is 3.

"const leven = require('leven');\nconsole.log(leven('kitten', 'sitting')); // 3"

Other packages similar to leven

Readme

Source

leven Build Status

Measure the difference between two strings
The fastest JS implementation of the Levenshtein distance algorithm

Install

$ npm install --save leven

Usage

var leven = require('leven');

leven('cat', 'cow');
//=> 2

Benchmark

$ npm run bench
         230,113 op/s » leven
         201,026 op/s » levenshtein-edit-distance
          40,454 op/s » fast-levenshtein
          28,664 op/s » levenshtein-component
          22,952 op/s » ld
          16,882 op/s » levdist
          11,180 op/s » levenshtein
           9,624 op/s » natural

CLI

$ npm install --global leven
$ leven --help

  Example
    leven cat cow
    2

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 07 Oct 2014

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