Package Exports
- query-objects
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (query-objects) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
filter-objects
Purpose
Given an array of objects returns those that satisfy some or all desired filters.
Contents
Installation
npm install filter-objects
Filtering objects
filter(arr, filters, operator)
Returns an array of all the objects in arr that satisfy the filters. operator can take two values every or 'some'. If 'every' is used then the returned objects satisfy every filter or alternatively if 'some' is used then the returned objects satisfy at least one of the filters.
Constructing filters
field - The name of the property we will filter on
value - The value of the property we will filter on
operator - The filter operator. Supported operators equals, contains, gt, gte, lt, lte
Examples
const filters = [
{
field: 'foo',
value: 1,
operator: 'equals'
},
{
field: 'bar',
value: 'baz',
operator: 'equals'
}
];
const arr = [
{
foo: 1,
bar: 'baz'
},
{
foo: 2,
bar: 'baz'
},
{
foo: 3,
bar: 'fiz'
}
];
let res = filter(arr, filters, 'every');Contributing
This project is work in progress and we'd love more people contributing to it.
- Fork the repo
- Apply your changes
- Write tests
- Submit your pull request
For feedback or suggestions you can drop us a line at support@avocarrot.com