@extra-lists/search

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

Usage no npm install needed!

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

README

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

Alternatives: search, searchAll.
Similar: find, search, searchValue.

This is part of package extra-lists.


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

lists.search(x, v => v === 4);
// undefined


References