@edgeros/deep-extend
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Deep Extend

Recursive object extending.

Install

$ npm install @edgeros/deep-extend

Usage

var deepExtend = require('@edgeros/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] }
*/

Package Sidebar

Install

npm i @edgeros/deep-extend

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

7.29 kB

Total Files

5

Last publish

Collaborators

  • clarkttfu
  • fu-starslights
  • epmbot
  • xieyuanbin
  • chengyonbin