0.4.0 • Published 5 years ago

return-deep-diff v0.4.0

Weekly downloads
4,083
License
ISC
Repository
github
Last release
5 years ago

Deep Diff

Build Status npm Coverage Status

Function returning an object representing the difference between two objects. The function is immutable-compliant as it does not affect the arguments.

Installation

npm install -S return-deep-diff

Usage

import deepDiff from 'return-deep-diff'

const objOne = {
  a: 1,
  b: {
    c: 2,
    d: 3
  },
  e: 4
}

const objTwo = {
  a: 1,
  b: {
    c: 2,
    d: 30,
    f: 50
  },
  e: 40
}

console.log(deepDiff(objOne, objTwo))
/*
returns:
  {
    b: {
      d: 30
    },
    e: 40
  }
*/

console.log(deepDiff(objOne, objTwo, true))
/*
returns:
  {
    b: {
      d: 30
      f: 50
    },
    e: 40
  }
*/

The two objects must share the exact same structure, which is defined by the first object. If a key is present in the second but not the first object, it will not be present in the diff object unless keepNewKeys equals true. The function does not mutate neither the first nor the second object.

0.4.0

5 years ago

0.3.0

6 years ago

0.2.9

7 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.5

7 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago