UNPKG

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