Socket
Socket
Sign inDemoInstall

apply-diff

Package Overview
Dependencies
1
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    apply-diff

Underscore/Lodash plugin to udate an object with properties of another object and make it deeply equal to it.


Version published
Weekly downloads
7
increased by250%
Maintainers
1
Install size
837 kB
Created
Weekly downloads
 

Readme

Source

_.applyDiff

Build Status

Lodash plugin to update an object with properties of another object and make it deeply equal to it.

To update an object only with difference it has with another object you can use this module to avoid replacing entire object with a new one.

For example if you have a destinationn object where it needs to be replaced with a sourcee object that has a very small difference with destinationn you can use this module as following:

var source = {
  a: {
    one: 1,
    two: 2,
    b: {
      c: {
        three: 3.14
      }
    }
  }
};
var destination = {
  a: {
    one: 1,
    two: 2,
    b: {
      c: {
        three: 3
      }
    }
  }
};

_.applyDiff(source, destination);

// now destination is deeply equal to source without being replaced entirely

Usage

In browser

include lodash and this module

<script src="lodash.js"></script>
<script src="apply-diff/index.js"></script>
_.applyDiff(source, destination);

In NodeJS

var _ = require('lodash');
require('apply-diff')(_);
_.applyDiff(source, destination);

Development

Install dependencies

npm install

npm run watch to run tests with watch

npm test ro run tests

License

MIT

Keywords

FAQs

Last updated on 07 Jun 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc