Skip to content
This repository has been archived by the owner on Mar 11, 2022. It is now read-only.

miguelmota/levenshtein

Repository files navigation

Levenshtein distance

Calculate the Levenshtein distance between two strings.

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

Demo

https://lab.miguelmota.com/levenshtein

Install

npm install levenshteinjs

Usage

const levenshteinDistance = require('levenshteinjs');

console.log(levenshteinDistance('foo', 'foo')) // 0
console.log(levenshteinDistance('foo', 'fob')) // 1
console.log(levenshteinDistance('flaw', 'lawn')) // 2
console.log(levenshteinDistance('kitten', 'sitting')) // 3

Test

npm test

License

MIT