most-frequent

0.0.3 • Public • Published

most-frequent

Track which value occurs most frequently

Build Status Coverage Status Code Climate Dependency Status devDependency Status

NPM

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

Readme

Keywords

none

Package Sidebar

Install

npm i most-frequent

Weekly Downloads

0

Version

0.0.3

License

MIT

Last publish

Collaborators

  • jamestalmage