@extra-set/scan-while

Finds first value not passing a test. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Usage no npm install needed!

<script type="module">
  import extraSetScanWhile from 'https://cdn.skypack.dev/@extra-set/scan-while';
</script>

README

Finds first value not passing a test. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Alternatives: scanWhile, scanUntil.

This is part of package extra-set.


set.scanWhile(x, ft);
// x:  a set
// ft: test function (v, v, x)
const set = require("extra-set");

var x = new Set([1, 2, 3, 4]);
set.scanWhile(x, v => v % 2 !== 0);
// 2                ^

set.scanWhile(x, v => v % 8 !== 0);
// undefined


References