@extra-array/find-index.min

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].

Usage no npm install needed!

<script type="module">
  import extraArrayFindIndexMin from 'https://cdn.skypack.dev/@extra-array/find-index.min';
</script>

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.

This is browserified, minified version of @extra-array/find-index.
It is exported as global variable array_findIndex.
CDN: unpkg, jsDelivr.

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