hasSubset - nodef/extra-map GitHub Wiki

Check if map has a subset.

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

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

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

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

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

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

References