Extended version of the count-map
module, providing range filter and easy
conversions.
This module exports one constructor:
Which works the same as the constructor exported from the original
count-map
module,
except the objects created have some additional methods:
Return the entries as a plain object. Useful for converting the counts to JSON.
opt
is an optional options object that supports these optional keys:
-
empty
: If set to something other thanundefined
, and the result would be empty, instead return this value.
Make a partial copy with only entries for which function decide
invoked with arguments (val, key, map)
returns a true-y value.
Return a CountMapPmb with only the entries whose count is at least min
and at most max
.
-
If
min
isnull
orundefined
, it is treated as negative infinity. -
If
max
isnull
orundefined
, it is treated as positive infinity. -
Example:
.rangeFilter(2)
impliesmax = undefined
and thus will report all entries that appeared at least twice.
Multiple acceptable ranges
can be given as an array of [min, max]
pairs.
Reports entries that match at least one range.
- Example:
.rangesFilter([ [null, 1], [3, null] ])
will report all entries except those who appeared exactly twice.
see test/usage.js:
- Needs more/better tests and docs.
ISC