https://github.com/tanhauhau/levenary
Find the shortest Levenshtein distance in the array
https://github.com/tanhauhau/levenary
Last synced: about 2 months ago
JSON representation
Find the shortest Levenshtein distance in the array
- Host: GitHub
- URL: https://github.com/tanhauhau/levenary
- Owner: tanhauhau
- License: mit
- Created: 2019-12-19T00:32:35.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T03:18:05.000Z (over 2 years ago)
- Last Synced: 2025-05-08T23:43:48.244Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 168 KB
- Stars: 24
- Watchers: 1
- Forks: 3
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# levenary
[](https://www.npmjs.com/package/levenary)
[](https://github.com/tanhauhau/levenary/actions)> Given a string, A and an array of strings XS, return the string X from XS whose Levenshtein distance from A is minimal.
## Install
```
$ npm install levenary
```## Usage
```js
import levenary from 'levenary';levenary('cat', ['cow', 'dog', 'pig']);
//=> 'cow'
```## Why `levenary`?
1. Based on [leven](https://github.com/sindresorhus/leven), the fastest JS implementation of the [Levenshtein distance algorithm](https://en.wikipedia.org/wiki/Levenshtein_distance)
1. Only 1 API. Simple and clean. If you want more, please use [didyoumean2](https://www.npmjs.com/package/didyoumean2).
1. [Flow](http://flow.org/) and [TypeScript](http://typescriptlang.org/) support.## Benchmark
```
$ npm run bench
``````
311,915 op/s » levenary
74,030 op/s » didyoumean
141,423 op/s » didyoumean2
```