katoikia-app/web-ui/web-react/node_modules/levenary/index.js

28 lines
605 B
JavaScript
Raw Normal View History

2022-07-06 04:15:11 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = levenArray;
var _leven = _interopRequireDefault(require("leven"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function levenArray(str, array) {
var minLeven = Number.POSITIVE_INFINITY;
var result = undefined;
for (var _i2 = 0; _i2 < array.length; _i2++) {
var item = array[_i2];
var distance = (0, _leven.default)(str, item);
if (distance < minLeven) {
minLeven = distance;
result = item;
}
}
return result;
}