2.1.22 • Published 5 years ago

@extra-object/is-subset v2.1.22

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Checks if object has a subset. :running: :package: :ledger:

Similar: subset, subsets, isSubset. This is part of package extra-object.

object.isSubset(x, y, [fc], [fm]);
// x:  an object
// y:  subset?
// fc: compare function (a, b)
// fm: map function (v, k, x)
const object = require('extra-object');

var x = {a: 1, b: 2, c: 3, d: 4};
var y = {b: 2, d: 4};
object.isSubset(x, y);
// true

var y = {b: -2, d: -4};
object.isSubset(x, y);
// false

object.isSubset(x, y, (a, b) => Math.abs(a) - Math.abs(b));
// true

object.isSubset(x, y, null, v => Math.abs(v));
// true

references