[core][js] calculate Damerau-Levenshtein distance only once