deep-extend
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Deep-extend is a handy JavaScript package which enables recursive extending of objects. This npm package allows for the seamless merging of the properties from one JavaScript object to another "deep" object, even if these are nested objects. It's particularly useful in situations where you need to overwrite some values of the first object with values from the second object while keeping intact non-overlapping keys.
Deep-extend package is simple to use. All you need to do is to install the package using $ npm install deep-extend
, and then require the package in your application with var deepExtend = require('deep-extend')
. After this, you can pass two or more objects to the deepExtend
function for merging.
Here is a usage example:
var deepExtend = require('deep-extend');
var obj1 = {
a: 1,
b: 2,
d: {
a: 1,
b: [],
c: { test1: 123, test2: 321 }
},
f: 5,
g: 123,
i: 321,
j: [1, 2]
};
var obj2 = {
b: 3,
c: 5,
d: {
b: { first: 'one', second: 'two' },
c: { test2: 222 }
},
e: { one: 1, two: 2 },
f: [],
g: (void 0),
h: /abc/g,
i: null,
j: [3, 4]
};
deepExtend(obj1, obj2);
console.log(obj1);
After execution, the properties from obj2
have been merged into obj1
, updating or extending the initial values.
The primary source of documentation for deep-extend package is available in the README of the GitHub repository at git://github.com/unclechu/node-deep-extend.git. This readme document provides a comprehensive guide on how to install, use and run unit tests on deep-extend. If you encounter any issues while using this npm package, you're encouraged to report them in the 'Issues' section of this github repository.