2.1.43 • Published 4 years ago
@extra-map/is-subset v2.1.43
Checks if map has a subset. :running: :package: :ledger:
Similar: subset, subsets, isSubset. This is part of package extra-map.
map.isSubset(x, y, [fc], [fm]);
// x: a map
// y: 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]]);
var y = new Map([['b', 2], ['d', 4]]);
map.isSubset(x, y);
// true
var y = new Map([['b', -2], ['d', -4]]);
map.isSubset(x, y);
// false
map.isSubset(x, y, (a, b) => Math.abs(a) - Math.abs(b));
// true
map.isSubset(x, y, null, v => Math.abs(v));
// true