@extra-iterable/search-right.min

Finds index of last value passing a test. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Usage no npm install needed!

<script type="module">
  import extraIterableSearchRightMin from 'https://cdn.skypack.dev/@extra-iterable/search-right.min';
</script>

README

Finds index of last value passing a test. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Alternatives: search, searchRight, searchAll.
Similar: search, scan, find.

This is part of package extra-iterable.

This is browserified, minified version of @extra-iterable/search-right.
It is exported as global variable iterable_searchRight.
CDN: unpkg, jsDelivr.


iterable.searchRight(x, ft);
// x:  an iterable
// ft: test function (v, i, x)
// → index of value, -1 if not found
const iterable = require("extra-iterable");

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

iterable.searchRight(x, v => v % 2 == 1);
// 4                 ^


References