@extra-iterable/find-index

Finds index of first value passing a test.

Downloads in past

Stats

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

Readme

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

iterable.findIndex(x, fn, [ths]);
// x:   an iterable
// fn:  test function (v, i, x)
// ths: this argument
// --> index of value, -1 if not found

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

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

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

references