npm.io
1.0.0 • Published 9 years ago

@f/find

Licence
MIT
Version
1.0.0
Deps
0
Vulns
0
Weekly
0
Stars
2

find

Build status Git tag NPM version Code style

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 search
  • fn - The predicate to use to search the array (accepts an item in the list and returns true/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