levenshtein-search
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -32,3 +32,3 @@ const { searchExact, reverse } = require('./utils') | ||
const [ dist, length ] = _expand(a, b, maxDist) | ||
const [dist, length] = _expand(a, b, maxDist) | ||
return dist + (b.length - length) <= maxDist | ||
@@ -224,3 +224,3 @@ } | ||
)), | ||
maxDist | ||
maxDist - distRight | ||
) | ||
@@ -227,0 +227,0 @@ if (distLeft === null) continue |
@@ -6,3 +6,7 @@ { | ||
"keywords": [ | ||
"Levenshtein Distance", "edit distance", "Levenshtein", "fuzzy", "search" | ||
"Levenshtein Distance", | ||
"edit distance", | ||
"Levenshtein", | ||
"fuzzy", | ||
"search" | ||
], | ||
@@ -12,5 +16,5 @@ "main": "index.js", | ||
"devDependencies": { | ||
"jest": "^23.6.0", | ||
"lodash": "^4.17.11", | ||
"standard": "^12.0.1" | ||
"jest": "^26.0.1", | ||
"lodash": "^4.17.15", | ||
"standard": "^14.3.4" | ||
}, | ||
@@ -27,7 +31,7 @@ "repository": { | ||
"scripts": { | ||
"check-only": "grep -c \"test.only\" test.js | python -c \"import sys; sys.exit(0 if int(sys.stdin.read()) == 0 else 1)\"", | ||
"check-only": "! grep 'test.only' tests/test.js -n", | ||
"lint": "standard", | ||
"test": "npm run lint && npm run check-only && jest" | ||
}, | ||
"version": "0.1.0" | ||
"version": "0.1.1" | ||
} |
@@ -0,0 +0,0 @@ # levenshtein-search |
10
test.js
@@ -25,9 +25,9 @@ /* global describe, expect, test */ | ||
// name: (needle, haystack, [index, ...]), | ||
'identical': ['abc', 'abc', [0]], | ||
'substring': ['abc', '-ab-abc-ab-', [4]], | ||
identical: ['abc', 'abc', [0]], | ||
substring: ['abc', '-ab-abc-ab-', [4]], | ||
'double first item': ['def', 'abcddefg', [4]], | ||
'missing second item': ['bde', 'abcdefg', []], | ||
'completely different': ['abc', 'def', []], | ||
'startswith': ['abc', 'abcd', [0]], | ||
'endswith': ['bcd', 'abcd', [1]], | ||
startswith: ['abc', 'abcd', [0]], | ||
endswith: ['bcd', 'abcd', [1]], | ||
'multiple matches': ['abc', '-abc-abc-abc-', [1, 5, 9]] | ||
@@ -118,3 +118,3 @@ } | ||
]], | ||
'substring': ['PATTERN', '----------PATTERN---------', [ | ||
substring: ['PATTERN', '----------PATTERN---------', [ | ||
[0, [[10, 17, 0]]], | ||
@@ -121,0 +121,0 @@ [1, [[10, 17, 0]]], |
Sorry, the diff of this file is not supported yet
28216