2.2.18 • Published 3 years ago
@extra-entries/has-subset v2.2.18
Checks if entries has a subset. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:
Alternatives: has, hasValue, hasEntry, hasSubset, hasPath. Similar: subset, subsets, hasSubset.
This is part of package extra-entries.
entries.hasSubset(x, y, [fc], [fm]);
// x: entries
// y: subset?
// fc: compare function (a, b)
// fm: map function (v, k, x)
const entries = require("extra-entries");
var x = [["a", 1], ["b", 2], ["c", 3], ["d", 4]];
var y = [["b", 2], ["d", 4]];
entries.hasSubset(x, y);
// true
var y = [["b", -2], ["d", -4]];
entries.hasSubset(x, y);
// false
entries.hasSubset(x, y, (a, b) => Math.abs(a) - Math.abs(b));
// true
entries.hasSubset(x, y, null, v => Math.abs(v));
// true