Package Exports
- deep-array-filter
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 (deep-array-filter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
deep-array-filter
Filters an array of objects.
Define your filter values:
the property $ will search in all keys.
let filter = {
$: wayne,
firstname: 'joh',
age: 18
address: {
city: 'Basel'
}
};FilterTypes
Define type of your filters:
If not defined it will default to includes.
let filterType = {
age: 'gt'
address: {
city: 'gt'
}
}Execute the filter
let filteredArr = filter(arr, values, filterTypes)Filters
Currently there are following filters defined:
- includes - substring matching
- gt - greater than
- lt - less than
If you need more, open an Issue or send a PR.
extend filterTypes
If you need more or different filters, you can provide you custom compare functions.
let filterType = {
age: 'customFilter'
}
let comparator = {
customFilter: (value, filter) => {
return value > filter;
}
}
let filteredArr = filter(arr, values, filterTypes, comparator)