find-by-array
v1.1.2
Published
little module to provide a more fluid find interface for arrays
Downloads
1
Maintainers
Readme
findBy
what?
A little module to provide a more fluid find interface for arrays. Allows prop name in function calls with value and predicate matching.
findBy uses a ES6 proxy, so a findBy array can be used in place of any array.
install
npm install find-by-array --save
use
const findBy = require('find-by-array'); findBy([{ id: 1 }, { id: 2 }]).findById(2); findBy([{ id: 1 }, { id: 2 }], 'filterBy').filterById(2); findBy([{ id: 1 }, { id: 2 }]).findById(id => id > 1); findBy([{ name: 'Bob', age: 20 }, { name: 'Susan', age: 21 }]).findByName('Susan'); findBy([{ name: 'Bob', age: 20 }, { name: 'Susan', age: 21 }], 'filterBy').filterByName('Susan'); findBy([{ name: 'Bob', age: 20 }, { name: 'Susan', age: 21 }]).findByAge(age => age > 20);