🚀 DAY 2 OF LAUNCH WEEK: Unify Your Security Stack with Socket Basics.Learn more →
Socket
Book a DemoInstallSign in
Socket

@doubletrade/fastest-levenshtein

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@doubletrade/fastest-levenshtein

Fastest Levenshtein distance implementation in JS.

latest
Source
npmnpm
Version
1.0.14
Version published
Maintainers
3
Created
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

levenshtein

FAQs

Package last updated on 07 Jul 2022

Did you know?

Socket

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