UNPKG

1.25 kBMarkdownView Raw
1Deep Extend
2===========
3
4Recursive 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
9Install
10-------
11
12```bash
13$ npm install deep-extend
14```
15
16Usage
17-----
18
19```javascript
20var deepExtend = require('deep-extend');
21var 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};
34var 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
49deepExtend(obj1, obj2);
50
51console.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: [],
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
69Unit testing
70------------
71
72```bash
73$ npm test
74```
75
76Changelog
77---------
78
79[CHANGELOG.md](./CHANGELOG.md)
80
81Any issues?
82-----------
83
84Please, report about issues
85[here](https://github.com/unclechu/node-deep-extend/issues).
86
87License
88-------
89
90[MIT](./LICENSE)