most-frequent
Track which value occurs most frequently
Usage
var f = ; f;f;f;f; f; // a and b are tied for most frequent//=> truef;//=> true f;//=> false; f; f;//=> true; f;//=> false; f;//=> 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