-
Notifications
You must be signed in to change notification settings - Fork 0
hasSubset
Subhajit Sahu edited this page Jun 28, 2020
·
10 revisions
Checks if lists has a subset. [:running:] [:vhs:] [:package:] [:moon:] [:ledger:]
Alternatives: [has], [hasValue], [hasEntry], [hasSubset], [hasPath].
Similar: [subset], [subsets], [hasSubset].
lists.isSubset(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