0.0.3 • Published 10 years ago
most-frequent v0.0.3
most-frequent
Track which value occurs most frequently
Usage
var f = require('most-frequent');
f.add('a');
f.add('a');
f.add('b');
f.add('b');
f.most('a'); // a and b are tied for most frequent
//=> true
f.most('b');
//=> true
f.uniquelyMost('a');
//=> false;
f.add('a');
f.uniquelyMost('a');
//=> true;
f.most('b');
//=> false;
f.count('a');
//=> 3;API
new MostFrequent()
Create a new MostFrequent instance (referred to as f in the rest of the documentation).
f.add(value)
Increment the count of value by one.
f.count(value)
Returns the count for value. (how many times add(..) has been called with that same value).
Should be a string or a number.
f.most(value)
returns true if value has a count greater than or equal to all other values.
f.uniquelyMost(value)
returns true if value has a count greater than all other values.
f.universal
true true if every call to add has been with the same value.
License
MIT © James Talmage
