1.1.0 • Published 6 years ago

objectwithin v1.1.0

Weekly downloads
5
License
ISC
Repository
-
Last release
6 years ago

ObjectWithin

Installation

npm install --save objectwithin

Usage

The object within function accepts two parameters, a small object and a large object. It will deeply compare the two, making sure EVERY field that is in the smaller object exists in the larger one.

const largeObj = {
  a: 1,
  b: 2,
  c: {
    d: 3,
    e: {
      f: 4,
      g: 6
    },
    h: 5
  },
  e: 7,
  d: 3,
  j: [
    1,
    2,
    3,
    {
      a: 7,
      b: 8
    },
    4
  ]
}

const smallObj = {
  a: 1,
  c: {
    e: {
      f: 4
    },
    h: 5
  },
  e: 7,
  j: [
    1,
    2,
    3,
    {
      a: 7
    }
  ]
}

expect( objectWithin(smallObj, largeObj) ).to.be.true;
// ==> true :)