@extra-lists/scan-until

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

Usage no npm install needed!

<script type="module">
  import extraListsScanUntil from 'https://cdn.skypack.dev/@extra-lists/scan-until';
</script>

README

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

Alternatives: scanWhile, scanUntil.

This is part of package extra-lists.


lists.scanUntil(x, ft);
// x:  lists
// ft: test function (v, k, x)
const lists = require('extra-lists');

var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 2]];
lists.scanUntil(x, v => v % 2 === 0);
// 'b'                       ^

lists.scanUntil(x, v => v % 8 === 0);
// undefined


References