1.0.0 • Published 8 years ago
@f/find-index v1.0.0
find-index
Find the index of an item in an array, given a predicate
Installation
$ npm install @f/find-index
Usage
var findIndex = require('@f/find-index')
findIndex([1, 2, 3], n => n === 3) === 2
API
findIndex(arr, fn, fromIndex)
arr
- Array to searchfn
- Predicate function that is called on each item. If it returns true, the index of that item is returned fromfindIndex
.fromIndex
- Optional. Defaults to 0. The starting place in the array to search from.
Returns: The index of the first item that fn
returns true for. If no such item is found, returns -1.
License
MIT
1.0.0
8 years ago