hasSubset - nodef/extra-lists GitHub Wiki

Check if lists has a subset.

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

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

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

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

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

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

References