-
Notifications
You must be signed in to change notification settings - Fork 0
hasSubset
Subhajit Sahu edited this page Dec 22, 2022
·
11 revisions
Check if ientries has a subset.
Alternatives: has, hasValue, hasEntry, hasSubset, hasPath.
Similar: randomSubset, subsets, hasSubset.
function hasSubset(x, y, fc, fm)
// x: ientries
// y: search subset
// fc: compare function (a, b)
// fm: map function (v, k, x)
const ientries = require('extra-ientries');
var x = [["a", 1], ["b", 2], ["c", 3], ["d", 4]];
var y = [["b", 2], ["d", 4]];
ientries.hasSubset(x, y);
// → true
var y = [["b", -2], ["d", -4]];
ientries.hasSubset(x, y);
// → false
ientries.hasSubset(x, y, (a, b) => Math.abs(a) - Math.abs(b));
// → true
ientries.hasSubset(x, y, null, v => Math.abs(v));
// → true