var str = 'тест тост тест тесто';
var words = str.split(' ');
var result = [];
for (var i = 0; i < words.length; i++) {
result.push(words[i]);
for (var j = i + 1; j < words.length; j++) {
if (levenshtein(words[i], words[j], {}) < 2) {
words.splice(j--, 1);
}
}
}