majority
v1.0.3
Published
A two-bit library to get the most popular value
Downloads
2
Readme
majority
A two-bit library to get the most popular value.
(new Majority(1, 1, 2, 2, 2, 3, 3)).value()
// 2
const majority = new Majority()
console.log(majority.value('foo'))
// foo
for (let i = 0; i < 5; ++i) majority.feed('Trump')
console.log(majority.value())
// Trump
for (let i = 0; i < 10; ++i) majority.feed('Biden')
for (let i = 0; i < 6; ++i) majority.feed('Hilary')
console.log(majority.value())
// Biden