@extra-iterable/search-right

Finds index of last value passing a test.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-iterable/search-right
512.5.222 years ago3 years agoMinified + gzip package size for @extra-iterable/search-right in KB

Readme

Finds index of last value passing a test. :package: :smileycat: :running: :vhs: :moon: :scroll: :newspaper: :bluebook:
Alternatives: search, searchRight, searchAll.
Similar: search, scan, find.

This is part of package extra-iterable.



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