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
Weekly downloads
8,720,840
decreased by-17.61%
Install size
20.8 kB

Weekly downloads

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 JS/TS implemenation of Levenshtein distance.
Measure the difference between two strings.

Build Status Coverage Status Language grade: JavaScript npm

$ npm i fastest-levenshtein

Usage

Node

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'

Deno

import {distance, closest} from 'https://deno.land/x/fastest_levenshtein/mod.ts'

// 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.

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. y-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 02 Aug 2022

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