Sha256: 026dc0931c6b2339779adad73d671f97723d1e322296106053b429550b129372
Contents?: true
Size: 446 Bytes
Versions: 225
Compression:
Stored size: 446 Bytes
Contents
'use strict'; function Words() {} Words.prototype.count = function (input) { var counts = {}; var words = input.toLowerCase() .replace(/[,."\/!&@$%\^\*;:{}()¡¿?]/g, ' ') .replace(/\s'(\w+)'\s/, ' '+'$1'+' ') .match(/\S+/g); words.forEach(function (word) { counts[word] = counts.hasOwnProperty(word) ? counts[word] + 1 : 1; }); return counts; }; module.exports = Words;
Version data entries
225 entries across 225 versions & 1 rubygems