The Damerau Levenshtein algorithim calculates a distance between two words in the same way that basic Levenshtein does but adds transpositions to the set of operations that it uses to calculate distance. This makes it much more reliable at finding similiar or alternate spellings of words. I was doing some nodejs work lately and needed such a function to clean up one of my datasets and so I ported this version from C# to Javascript.