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