New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

deep-sync

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-sync

Recursively synchronizes two JS objects where the target becomes the source, without changing the target values for the keys that it has in common with the source.

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

deep-sync

Recursively synchronizes two JSON / Javascript objects where the target becomes the source, without changing the target values for the keys that it has in common with the source. If overwrite option is passed, existent keys will be overwritten as well. Keys that exist in the target but not in the source will be removed from the dict.

method

var deepSync = require('deep-sync')
deepSync(target, source, overwrite)

example

var baseObj = {a: 1, b:2, c:3, d: { e:4 }}
var target = {a:1, b:1}

deepSync(target, baseObj, false)
// {a:1, b:1, c:3, d: { e:4 }}

deepSync(target, baseObj, true)
// {a:1, b:2, c:3, d: { e:4 }}

error handling

Throws an error of instance TypeError for invalid input

try {
deepSync(a,b)
} catch (e) {
  if (e instanceof TypeError) {
    console.log('Invalid objects')
  }
}

install

With npm do:

npm install deep-sync

test

With npm do:

npm test

license

MIT.

Keywords

Merge

FAQs

Package last updated on 15 Sep 2015

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