npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

elude

1.0.1 • Public • Published

elude

Elude values from a collection with a powerfull include / exclude config.

npm version Build Status Coverage Status dependencies Status


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<*>

install

npm i elude

Downloadsweekly downloads

10

version

1.0.1

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability