Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tanhauhau/levenary
Find the shortest Levenshtein distance in the array
https://github.com/tanhauhau/levenary
Last synced: 6 days 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 (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T03:18:05.000Z (almost 2 years ago)
- Last Synced: 2024-10-16T15:47:47.463Z (20 days ago)
- Language: JavaScript
- Homepage:
- Size: 168 KB
- Stars: 24
- Watchers: 2
- Forks: 3
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# levenary
[![npm-version](https://img.shields.io/npm/v/levenary.svg)](https://www.npmjs.com/package/levenary)
[![github-actions](https://github.com/tanhauhau/levenary/workflows/CI/badge.svg)](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
```