@extra-map/scan-while

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


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

var x = new Map([["a", 1], ["b", 2], ["c", 3], ["d", 2]]);
map.scanWhile(x, v => v % 2 !== 0);
// "b"                       ^

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


References