@simov/deep-extend

1.0.0 • Public • Published

Deep Extend

NOTE: this is a fork of https://github.com/unclechu/node-deep-extend with this little patch applied on top of it https://github.com/simov/node-deep-extend/commit/e26b5aca2535299db00cbc35cd891c0923a01fd6

Recursive object extending.

Build Status

NPM

Install

$ npm install deep-extend

Usage

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);
/*
{ a: 1,
  b: 3,
  d:
   { a: 1,
     b: { first: 'one', second: 'two' },
     c: { test1: 123, test2: 222 } },
  f: [],
  g: undefined,
  c: 5,
  e: { one: 1, two: 2 },
  h: /abc/g,
  i: null,
  j: [3, 4] }
*/

Unit testing

$ npm test

Changelog

CHANGELOG.md

Any issues?

Please, report about issues here.

License

MIT

Package Sidebar

Install

npm i @simov/deep-extend

Weekly Downloads

75,422

Version

1.0.0

License

MIT

Unpacked Size

9.51 kB

Total Files

6

Last publish

Collaborators

  • simov