main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | Deep Extend
|
---|
| 2 | ===========
|
---|
| 3 |
|
---|
| 4 | Recursive object extending.
|
---|
| 5 |
|
---|
| 6 | [](https://travis-ci.org/unclechu/node-deep-extend)
|
---|
| 7 |
|
---|
| 8 | [](https://nodei.co/npm/deep-extend/)
|
---|
| 9 |
|
---|
| 10 | Install
|
---|
| 11 | -------
|
---|
| 12 |
|
---|
| 13 | ```bash
|
---|
| 14 | $ npm install deep-extend
|
---|
| 15 | ```
|
---|
| 16 |
|
---|
| 17 | Usage
|
---|
| 18 | -----
|
---|
| 19 |
|
---|
| 20 | ```javascript
|
---|
| 21 | var deepExtend = require('deep-extend');
|
---|
| 22 | var 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 | };
|
---|
| 35 | var 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 |
|
---|
| 50 | deepExtend(obj1, obj2);
|
---|
| 51 |
|
---|
| 52 | console.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 |
|
---|
| 70 | Unit testing
|
---|
| 71 | ------------
|
---|
| 72 |
|
---|
| 73 | ```bash
|
---|
| 74 | $ npm test
|
---|
| 75 | ```
|
---|
| 76 |
|
---|
| 77 | Changelog
|
---|
| 78 | ---------
|
---|
| 79 |
|
---|
| 80 | [CHANGELOG.md](./CHANGELOG.md)
|
---|
| 81 |
|
---|
| 82 | Any issues?
|
---|
| 83 | -----------
|
---|
| 84 |
|
---|
| 85 | Please, report about issues
|
---|
| 86 | [here](https://github.com/unclechu/node-deep-extend/issues).
|
---|
| 87 |
|
---|
| 88 | License
|
---|
| 89 | -------
|
---|
| 90 |
|
---|
| 91 | [MIT](./LICENSE)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.