Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deep-diff

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-diff

Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.

  • 0.3.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8M
increased by4.54%
Maintainers
1
Weekly downloads
 
Created

What is deep-diff?

The deep-diff npm package is a utility for identifying differences between two JavaScript objects. It helps in understanding changes between object versions and can be particularly useful in debugging and data tracking scenarios.

What are deep-diff's main functionalities?

Difference Detection

This feature allows you to detect differences between two objects. The code sample shows how to use the diff function to compare two objects and log the differences.

const diff = require('deep-diff').diff;
const lhs = { name: 'my object', detail: { it: 'has', an: 'array', with: ['a', 'few', 'elements'] } };
const rhs = { name: 'updated object', detail: { it: 'has', an: 'array', with: ['a', 'few', 'more', 'elements', { than: 'before' }] } };
const differences = diff(lhs, rhs);
console.log(differences);

Observing Changes

This feature allows you to observe changes and apply them to the original object. The code sample demonstrates how to observe differences and apply these changes to update the object.

const diff = require('deep-diff').observableDiff;
const applyChange = require('deep-diff').applyChange;
let obj = { name: 'original' };
let newObj = { name: 'updated' };
diff(obj, newObj, function (d) {
  applyChange(obj, newObj, d);
});
console.log(obj);

Other packages similar to deep-diff

Keywords

FAQs

Package last updated on 01 May 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc