You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

deep-object-changes

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-object-changes

Compares two objects, an original and an updated version and returns an object with only the changes.

1.0.4
latest
Source
npmnpm
Version published
Weekly downloads
30
-3.23%
Maintainers
1
Weekly downloads
 
Created
Source

deep-object-changes

npm size issues stars

Compares two objects, an original and an updated version and returns an object with only the changes.

Will deep compare objects recursively, but will only shallow compare arrays.

This module is useful for working out the bare minimum payload needed to send to a server.

Example

  import deepObjectChanges from 'deep-object-changes';
  
  const EXAMPLE_USER_RES = {
    firstName: 'Emperor',
    lastName: 'Palpatine',
    age: 75,
    location: {
      street: 'Death Star',
      postCode: 'SPACE'
    }
  };
  
  const EXAMPLE_CHANGED_USER = {
    firstName: 'Emperor',
    lastName: 'Palpatine',
    age: 85,
     location: {
      street: 'Death Star',
      postCode: 'GALAXY'
    }
  }
  
  deepObjectChanges(EXAMPLE_USER_RES, EXAMPLE_CHANGED_USER);
  
  /**
    Outputs: 
    
    {
      age: 85,
       location: {
        postCode: 'GALAXY'
      }
    }
 */
  

Keywords

compare

FAQs

Package last updated on 14 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts