Socket
Socket
Sign inDemoInstall

fastest-levenshtein

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fastest-levenshtein

Fastest Levenshtein distance implementation in JS.


Version published
Maintainers
1
Install size
11.0 kB
Created

Package description

What is fastest-levenshtein?

The fastest-levenshtein npm package is a JavaScript library that provides an efficient implementation of the Levenshtein distance algorithm, which is used to measure the difference between two sequences of characters. The package is optimized for performance and is useful for tasks such as fuzzy matching, spell checking, and similarity checking between strings.

What are fastest-levenshtein's main functionalities?

distance

Calculates the Levenshtein distance between two strings, which is the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into the other.

const { distance } = require('fastest-levenshtein');
const dist = distance('kitten', 'sitting');
console.log(dist); // Output: 3

Other packages similar to fastest-levenshtein

Readme

Source

fastest-levenshtein :rocket:

Fastest JavaScript implementation of the Levenshtein distance algorithm - (up to 10x+ faster than closest competitor). This algorithm can be used to measure the similarity of two strings.

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.

Build Status Coverage Status

$ npm i fastest-levenshtein

Usage

const {distance, closest} = require('fastest-levenshtein')

// Print levenshtein-distance between 'fast' and 'faster' 
console.log(distance('fast', 'faster'))
//=> 2

// Print string from array with lowest edit-distance to 'fast'
console.log(closest('fast', ['slow', 'faster', 'fastest']))
//=> 'faster'

Benchmark

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. fastest-levenshtein is a lot faster in all cases.

Test TargetN=4N=8N=16N=32N=64N=128N=256N=512N=1024
fastest-levenshtein44423237021076445951049291.586.6422.245.473
js-levenshtein2126110030293982422357.6214.773.7170.934
leven196886884160643611730.347.6041.9290.478
fast-levenshtein185776112126534589.4122.705.6761.4280.348
levenshtein-edit-distance229687445149340910928.077.0951.7890.445

Relative Performance

This image shows the relative performance between fastest-levenshtein and js-levenshtein (the 2nd fastest). fastest-levenshtein is always a lot faster. x-axis shows "times faster".

Benchmark

License

This project is licensed under the MIT License - see the LICENSE.md file for details

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