Sha256: 7bd11d069d9f0d8b43737040c6d757930d8ea8f54d1cc917a8819b0e6588b9c7
Contents?: true
Size: 625 Bytes
Versions: 255
Compression:
Stored size: 625 Bytes
Contents
'use strict'; function Anagram(word) { this.word = word; } Anagram.prototype.matches = function (words) { words = Array.isArray(words) ? words : [].slice.call(arguments, 0); return words.filter(function (candidate) { return !sameWord(this.word, candidate) && isAnagram(this.word, candidate); }, this); } function sameWord(word, candidate) { return word.toLowerCase() === candidate.toLowerCase(); } function isAnagram(word, candiate) { return normalize(word) === normalize(candiate); } function normalize(string) { return string.toLowerCase().split('').sort().toString(); } module.exports = Anagram;
Version data entries
255 entries across 255 versions & 1 rubygems