# js-levenshtein

> The most efficient JS implementation calculating the Levenshtein distance, i.e. the difference between two strings.

Latest version **1.1.6** (published 2019-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-levenshtein
pnpm add js-levenshtein
yarn add js-levenshtein
bun add js-levenshtein
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.6 |
| Published | 2019-01-10 |
| First published | 2017-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/js-levenshtein) |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 510 |
| Author | Gustaf Andersson |
| Maintainers | ggustf |
| Keywords | levenshtein, distance, algorithm, algo, string, difference, diff, fast, fuzzy, similar, similarity, compare, comparison, edit, text, match, matching |

## Links

- npm: https://www.npmjs.com/package/js-levenshtein
- Repository: https://github.com/gustf/js-levenshtein
- Homepage: https://github.com/gustf/js-levenshtein#readme
- Issues: https://github.com/gustf/js-levenshtein/issues
- npm.io page: https://npm.io/package/js-levenshtein

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 1.1.6 (latest) — 2019-01-10
- 1.1.5 — 2019-01-08
- 1.1.4 — 2018-09-27
- 1.1.3 — 2017-10-01
- 1.1.2 — 2017-06-19
- 1.1.1 — 2017-06-03
- 1.1.0 — 2017-06-01
- 1.0.0 — 2017-05-14

## README

# js-levenshtein [![Build Status](https://travis-ci.org/gustf/js-levenshtein.svg?branch=master)](https://travis-ci.org/gustf/js-levenshtein)

A very efficient JS implementation calculating the Levenshtein distance, i.e. the difference between two strings.

Based on Wagner-Fischer dynamic programming algorithm, optimized for speed and memory
 - use a single distance vector instead of a matrix
 - loop unrolling on the outer loop
 - remove common prefixes/postfixes from the calculation
 - minimize the number of comparisons
 
## Install

```
$ npm install --save js-levenshtein
```


## Usage

```js
const levenshtein = require('js-levenshtein');

levenshtein('kitten', 'sitting');
//=> 3
```


## Benchmark

```
$ npm run bench
  
                      50 paragraphs, length max=500 min=240 avr=372.5
             162 op/s » js-levenshtein
              98 op/s » talisman
              94 op/s » levenshtein-edit-distance
              85 op/s » leven
              39 op/s » fast-levenshtein

                      100 sentences, length max=170 min=6 avr=57.5
           3,076 op/s » js-levenshtein
           2,024 op/s » talisman
           1,817 op/s » levenshtein-edit-distance
           1,633 op/s » leven
             800 op/s » fast-levenshtein

                      2000 words, length max=20 min=3 avr=9.5
           3,119 op/s » js-levenshtein
           2,416 op/s » talisman
           2,141 op/s » levenshtein-edit-distance
           1,855 op/s » leven
           1,260 op/s » fast-levenshtein
```

Benchmarks was performed with node v8.12.0 on a MacBook Pro 15", 2.9 GHz Intel Core i9

## License

MIT © Gustaf Andersson

---
_Source: https://npm.io/package/js-levenshtein · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
