@extra-lists/has-subset.min

Checks if lists has a subset. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Usage no npm install needed!

<script type="module">
  import extraListsHasSubsetMin from 'https://cdn.skypack.dev/@extra-lists/has-subset.min';
</script>

README

Checks if lists has a subset. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:

Alternatives: has, hasValue, hasEntry, hasSubset, hasPath.
Similar: subset, subsets, hasSubset.

This is part of package extra-lists.

This is browserified, minified version of @extra-lists/has-subset.
It is exported as global variable lists_hasSubset.
CDN: unpkg, jsDelivr.


lists.hasSubset(x, y, [fc], [fm]);
// x:  lists
// y:  subset?
// fc: compare function (a, b)
// fm: map function (v, k, x)
const lists = require('extra-lists');

var x = [['a', 'b', 'c', 'd'], [1, 2, 3, 4]];
var y = [['b', 'd'], [2, 4]];
lists.hasSubset(x, y);
// true

var y = [['b', 'd'], [-2, -4]];
lists.hasSubset(x, y);
// false

lists.hasSubset(x, y, (a, b) => Math.abs(a) - Math.abs(b));
// true

lists.hasSubset(x, y, null, v => Math.abs(v));
// true


References