diff

Type:Function
Status:stable
Since:1.0.0
Platform:jsnode
@blackbyte.sugar.shared.object

This function take two objects and return an object that contains only what has been changed between the two. This function is a simple wrapper around the nice object-diff package from Thomas Jensen that you can find here: https://www.npmjs.com/package/object-diff

Params

  1. object1*-Object

    The first object used for the diff process

  2. object2*-Object

    The second object used for the diff process

  3. settings{}Object

    An object of settings to configure the diff process:

Return

  1. -Object

    The object that contains only the differences between the two

Example

import { diff } from '@blackbyte/sugar/object';
const myObject1 = {
   hello: 'world',
   plop: 'yop'
};
const myObject2 = {
   coco: 'plop',
   hello: 'hey!',
   plop: 'yop'
};
diff(myObject1, myObject2);
{
   coco: 'plop',
   hello: 'hey!'
}

Todo

  • testsnormal