@zitro/edit-distance

1.0.1 • Public • Published

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

Package Sidebar

Install

npm i @zitro/edit-distance

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • zitro