elude
v1.0.1
Published
Elude values from a collection with a powerfull include / exclude config.
Downloads
1
Readme
Install
npm install --save elude
const elude = require('elude');
Usage
const beatles = [
{ name: 'John', alive: false, age: 40 },
{ name: 'Paul', alive: true, age: 74 },
{ name: 'George', alive: false, age: 57 },
{ name: 'Ringo', alive: true, age: 76 },
];
const alive = elude(beatles, { include: 'alive' }); // Paul, Ringo
const favorites = elude(beatles, { exclude: { name: /^[GR]/ } }); // John, Paul
const shouldRetire = elude(beatles, {
include: (member) => member.age > 60,
exclude: { name: 'Paul' },
}); // Ringo
Matchr
Elude uses matchr for its powerfull value matching. Be sure to check all its options.
API
elude( collection
:Array<\*>
[, options:object
])
- options.include:
* | Array<*>
- options.exclude:
* | Array<*>
elude.one( value
:\*
[, options:object
])
- options.include:
* | Array<*>
- options.exclude:
* | Array<*>