nearest-string
![NPM version](https://img.shields.io/npm/v/nearest-string.svg)
Find the nearest string with a given string (used Levenstein distance for compare string).
Install
npm install --save nearest-string
Usage
Basic usage:
var nearestString = require('nearest-string');
var strings = [
'foo',
'bar',
'baz'
];
var nearestStringKey = nearestString(strings, 'fooo').key;
var nearestStringValue = nearestString(strings, 'fooo').value;
var nearestStringDistance = nearestString(strings, 'fooo').distance;
var nearestStringDistances = nearestString(strings, 'fooo').distances;
If you want to find nearest string case insensitive use third argument as true (it's false by default):
nearestString(strings, 'fooo', false).distance;
nearestString(strings, 'Fooo', false).distance;
nearestString(strings, 'fooo', true).distance;
nearestString(strings, 'Fooo', true).distance;
Test
npm test