Miss any of our Open RFC calls?Watch the recordings here! »

@extra-iterable/scan-until-right

2.5.12 • Public • Published

Scans from right, until a test passes. 🏃 📼 📦 🌔 📒

Alternatives: scanWhile, scanWhileRight, scanUntil, scanUntilRight.
Similar: search, scan, find.
This is part of package extra-iterable.

iterable.scanUntilRight(x, ft);
// x:  an iterable
// ft: test function (v, i, x)
// --> first index where test fails till end
const iterable = require('extra-iterable');
 
var x = [1, 1, 2, 2, 3, 3, 4, 4];
iterable.scanUntilRight(x, v => v % 3 === 0);
// 6                       ^
 
iterable.scanUntilRight(x, v => v % 2 === 0);
// 8                            ^
 
iterable.scanUntilRight(x, v => v % 6 === 0);
// 0    ^

references

Install

npm i @extra-iterable/scan-until-right

DownloadsWeekly Downloads

43

Version

2.5.12

License

MIT

Unpacked Size

7.17 kB

Total Files

14

Last publish

Collaborators

  • avatar