Skip to content

hasSubset

Subhajit Sahu edited this page Jun 28, 2020 · 6 revisions

Checks if object has a subset. 🏃 📼 📦 🌔 📒

Similar: subset, subsets, hasSubset.

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

Clone this wiki locally