1.1.2 • Published 5 years ago

find-by v1.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Find By

Build Status

Small helper to assist you with finding/filtering elements in an array by a specific key.

Install

npm install find-by --save

Example

const by = require('find-by')

const list = [
  { title: 'A New Hope', episode: 'IV' },
  { title: 'The Empire Strikes Back', episode: 'V' },
  { title: 'Return of the Jedi', episode: 'VI' }
]

console.log(list.find(by('episode', 'V')).title)
// => The Empire Strikes Back

For common keys there are also the shorter versions by.id, by.slug and by.type:

const by = require('find-by')

const list = [
  { id: 15, name: 'Foo' },
  { id: 42, name: 'Bar' },
  { id: 10, name: 'Baz' }
]

console.log(list.find(by.id(42)).name)
// => Bar
1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago