2.2.10 • Published 3 years ago
@extra-lists/has-subset v2.2.10
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.
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