Frequency keeps track of how many times a particular value is seen, but
unlike a Map it does not store the data. By default compares
items by value (via JSON.stringify).
Fires change event when items are added or it is cleared.
Overview
constfh = Trackers.frequency(); fh.add(value); // adds a value fh.clear(); // clears all data fh.keys() / .values() // returns an iterator for keys and values fh.toArray(); // returns an array of data in the shape [[key,freq],[key,freq]...]
Usage
constfh = Trackers.frequency(); fh.add(`apples`); // Count an occurence of `apples` fh.add(`oranges)`; fh.add(`apples`);
constfh = Trackers.frequency( person=>person.name); // All people with name `Samantha` will be counted in same group fh.add({name:`Samantha`, city:`Brisbane`});
Frequency keeps track of how many times a particular value is seen, but unlike a Map it does not store the data. By default compares items by value (via JSON.stringify).
Create with Trackers.frequency.
Fires
change
event when items are added or it is cleared.Overview
Usage
Custom key string