@extra-lists/scan-while.min

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 extraListsScanWhileMin from 'https://cdn.skypack.dev/@extra-lists/scan-while.min';
</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.

This is browserified, minified version of @extra-lists/scan-while.
It is exported as global variable lists_scanWhile.
CDN: unpkg, jsDelivr.


lists.scanWhile(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.scanWhile(x, v => v % 2 !== 0);
// 'b'                       ^

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


References