Skip to content

Morriphi/findBy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

little module to provide a more fluid find interface for arrays

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors