Create frequency lists
var FrequencyList = require('frequency-list'),
list = new FrequencyList;
list.add('hi')
.add('how are you')
.add('whats up')
.add('hi');
list.has('how are you') // true
list.size('hi') // 2
list.size('oh no') // 0
list.remove('hi')
list.unique('hi') // true
$ component install matthewmueller/frequency-list
Initialize the FrequencyList
with an optional array of values
Add a word or phrase to the frequency list
Remove a word or phrase from the frequency list.
Checks to see if a word or phrase exists in the list.
Gets the number of occurences of the given str
. If the string is not in the list, the size will be 0.
Returns true if str
occurs exactly once. Alias for size(str) === 1
.
Returns the raw frequency list. You may also use the alias toJSON()
.
list.values(); //=> { 'hi' : 2, 'how are you' : 1, 'whats up' : 1 }
MIT