Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # levenary
  2. [![npm-version](https://img.shields.io/npm/v/levenary.svg)](https://www.npmjs.com/package/levenary)
  3. [![github-actions](https://github.com/tanhauhau/levenary/workflows/CI/badge.svg)](https://github.com/tanhauhau/levenary/actions)
  4. > Given a string, A and an array of strings XS, return the string X from XS whose Levenshtein distance from A is minimal.
  5. ## Install
  6. ```
  7. $ npm install levenary
  8. ```
  9. ## Usage
  10. ```js
  11. import levenary from 'levenary';
  12. levenary('cat', ['cow', 'dog', 'pig']);
  13. //=> 'cow'
  14. ```
  15. ## Why `levenary`?
  16. 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)
  17. 1. Only 1 API. Simple and clean. If you want more, please use [didyoumean2](https://www.npmjs.com/package/didyoumean2).
  18. 1. [Flow](http://flow.org/) and [TypeScript](http://typescriptlang.org/) support.
  19. ## Benchmark
  20. ```
  21. $ npm run bench
  22. ```
  23. ```
  24. 311,915 op/s » levenary
  25. 74,030 op/s » didyoumean
  26. 141,423 op/s » didyoumean2
  27. ```