find-index

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
1 KB
Returns the index of the first element of the list which matches the predicate, or `-1` if no element matches.
1 contributor
Install find-index as a package?
Copied
npm i @bit/justin-capalbo.ramda.find-index
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
findIndex (
fn:Function,
list:Array
) : Number

Returns the index of the first element of the list which matches the predicate, or -1 if no element matches.

Acts as a transducer if a transformer is given in list position.

Example
const xs = [{a: 1}, {a: 2}, {a: 3}];
     R.findIndex(R.propEq('a', 2))(xs); //=> 1
     R.findIndex(R.propEq('a', 4))(xs); //=> -1
Arguments
fn: Function

The predicate function used to determine if the element is the desired one.

list: Array

The array to consider.

Returns
Number

The index of the element found, or `-1`.

Help and resources