Javascript Rewrite of Simmetrics Levenshtein distance calculation