1 | Deep Extend
|
2 | ===========
|
3 |
|
4 | Recursive object extending.
|
5 |
|
6 | [![NPM](https://nodei.co/npm/deep-extend.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/deep-extend/)
|
7 | [![NPM](https://nodei.co/npm-dl/deep-extend.png?height=3)](https://nodei.co/npm/deep-extend/)
|
8 |
|
9 | Install
|
10 | -------
|
11 |
|
12 | ```bash
|
13 | $ npm install deep-extend
|
14 | ```
|
15 |
|
16 | Usage
|
17 | -----
|
18 |
|
19 | ```javascript
|
20 | var deepExtend = require('deep-extend');
|
21 | var obj1 = {
|
22 | a: 1,
|
23 | b: 2,
|
24 | d: {
|
25 | a: 1,
|
26 | b: [],
|
27 | c: { test1: 123, test2: 321 }
|
28 | },
|
29 | f: 5,
|
30 | g: 123,
|
31 | i: 321,
|
32 | j: [1, 2]
|
33 | };
|
34 | var obj2 = {
|
35 | b: 3,
|
36 | c: 5,
|
37 | d: {
|
38 | b: { first: 'one', second: 'two' },
|
39 | c: { test2: 222 }
|
40 | },
|
41 | e: { one: 1, two: 2 },
|
42 | f: [],
|
43 | g: (void 0),
|
44 | h: /abc/g,
|
45 | i: null,
|
46 | j: [3, 4]
|
47 | };
|
48 |
|
49 | deepExtend(obj1, obj2);
|
50 |
|
51 | console.log(obj1);
|
52 | /*
|
53 | { a: 1,
|
54 | b: 3,
|
55 | d:
|
56 | { a: 1,
|
57 | b: { first: 'one', second: 'two' },
|
58 | c: { test1: 123, test2: 222 } },
|
59 | f: null,
|
60 | g: undefined,
|
61 | c: 5,
|
62 | e: { one: 1, two: 2 },
|
63 | h: /abc/g,
|
64 | i: null,
|
65 | j: [3, 4] }
|
66 | */
|
67 | ```
|
68 |
|
69 | Unit testing
|
70 | ------------
|
71 |
|
72 | ```bash
|
73 | $ npm test
|
74 | ```
|
75 |
|
76 | Changelog
|
77 | ---------
|
78 |
|
79 | [CHANGELOG.md](./CHANGELOG.md)
|
80 |
|
81 | Any issues?
|
82 | -----------
|
83 |
|
84 | Please, report about issues
|
85 | [here](https://github.com/unclechu/node-deep-extend/issues).
|
86 |
|
87 | License
|
88 | -------
|
89 |
|
90 | [MIT](./LICENSE)
|