2.2.5 • Published 3 years ago

@extra-object/has-subset.min v2.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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

Alternatives: has, hasValue, hasEntry, hasSubset, hasPath. Similar: subset, subsets, hasSubset. This is part of package extra-object.

This is browserified, minified version of @extra-object/has-subset. It is exported as global variable object_hasSubset. CDN: unpkg, jsDelivr.

object.hasSubset(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.hasSubset(x, y);
// true

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

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

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

references

2.2.5

3 years ago

2.2.4

4 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago