zaku:deep-extend

v0.9.1Published 6 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

deep-extend

Build Status

Recursive object extending.

Port from https://github.com/unclechu/node-deep-extend

Usage

1var obj1 = {
2    a: 1,
3    b: 2,
4    d: {
5        a: 1,
6        b: [],
7        c: { test1: 123, test2: 321 }
8    },
9    f: 5,
10    g: 123
11};
12var obj2 = {
13    b: 3,
14    c: 5,
15    d: {
16        b: { first: 'one', second: 'two' },
17        c: { test2: 222 }
18    },
19    e: { one: 1, two: 2 },
20    f: [],
21    g: (void 0)
22};
23
24deepExtend(obj1, obj2);
25
26console.log(obj1);
27/*
28    { a: 1,
29      b: 3,
30      d:
31       { a: 1,
32         b: { first: 'one', second: 'two' },
33         c: { test1: 123, test2: 222 } },
34      f: [],
35      c: 5,
36      e: { one: 1, two: 2 },
37      g: undefined }
38*/