Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 1.23 KB

Readme.md

File metadata and controls

45 lines (29 loc) · 1.23 KB

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