simple-filter
A small wrapper around crossfilter to make querying simpler
Installation
Install with component(1):
$ component install Wizcorp/simple-filter
API
Create a crossfilter
var data = object object etc...;var indexes = { return valueid }; // both values are optionalvar filter = data indexes;
addIndex(name, func)
Create an index name
using function func
.
// create an index named name for the lowercase value of the namefilter;
delIndex(name)
Delete index with given name
.
filter;
hasIndex(name)
Does index name
exists.
filter;
addRecords(data)
Add one or more values to the filter data
filter;
delRecords(filters)
Delete records based on given filter, see get
for more details about filters
// delete row with id "foobar"filter;// delete all datafilter;
get
Get records from the filter
// add an index on name and age, and feed lots of lines containing valuevar filter = data;filter;filter; // get all people that are 20 years old, sort by namefilter; // filters also support comparison operators (<, >, >= or <=) for numbers// for example get all people under 18 years oldfilter; // or all the people between 20 and 30filter; // or all the people whose name start by "chris", sorted by agefilter;
size()
Give the amount of records in the filter
License
MIT