1.0.0 • Published 8 years ago
@f/find v1.0.0
find
Lookup an element in a list using a predicate
Installation
$ npm install @f/find
Usage
var find = require('@f/find')
find(users, user => user.username === 'micro-js')
API
find(arr, fn, fromIndex)
arr
- The array to searchfn
- The predicate to use to search the array (accepts an item in the list and returnstrue/false
).fromIndex
- Optional, starting index. Defaults to zero.
Returns: Either the first element within arr
for which fn
returns true, or null
if none is found.
License
MIT
1.0.0
8 years ago