@extra-array/find-index

Finds index of leftmost value passing a test.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-array/find-index
1402.9.122 years ago4 years agoMinified + gzip package size for @extra-array/find-index in KB

Readme

Finds index of leftmost value passing a test. :running: :vhs: :package: :moon: :ledger:
Alternatives: findIndex, findIndices.
Similar: find, findIndex.
This is part of package extra-array.

array.findIndex(x, fn);
// x:  an array
// fn: test function (v, i, x)
// --> index of value, -1 if not found

const array = require('extra-array');

var x = [1, 2, 3, 4, 5];
array.findIndex(x, v => v % 2 == 0);
// 1        ^

array.findIndex(x, v => v % 2 == 1);
// 0     ^

references