1.0.1 • Published 7 years ago

@zitro/edit-distance v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

Edit Distance

npm Dependencies Build Status License

A tiny optimized package which finds the Levenshtein distance (edit distance) between two words. Having two strings of length N and M, the algorithm has O(N*M) complexity and uses O(N) additional space. The comparison is case sensitive.

Installation

npm install --save @zitro/edit-distance

Usage

import editDistance from "@zitro/edit-distance";

editDistance("jelly", "fully"); // === 2 (replace 2 letters "je" to "fu")
editDistance("cars", "girls"); // === 3 (replace 2 letters "ca" to "gi", add 1 letter "l")
editDistance(["c", "a", "r", "s"], ["g", "i", "r", "l", "s"]); // yields the same result

License

MIT © Nikita Savchenko