1 | var forOwn = require('./forOwn');
|
2 | var isPlainObject = require('../lang/isPlainObject');
|
3 |
|
4 | |
5 |
|
6 |
|
7 | function deepFillIn(target, defaults){
|
8 | var i = 0,
|
9 | n = arguments.length,
|
10 | obj;
|
11 |
|
12 | while(++i < n) {
|
13 | obj = arguments[i];
|
14 | if (obj) {
|
15 |
|
16 | forOwn(obj, function(newValue, key) {
|
17 | var curValue = target[key];
|
18 | if (curValue == null) {
|
19 | target[key] = newValue;
|
20 | } else if (isPlainObject(curValue) &&
|
21 | isPlainObject(newValue)) {
|
22 | deepFillIn(curValue, newValue);
|
23 | }
|
24 | });
|
25 | }
|
26 | }
|
27 |
|
28 | return target;
|
29 | }
|
30 |
|
31 | module.exports = deepFillIn;
|
32 |
|
33 |
|