Code coverage report for object/deepFillIn.js

Statements: 100% (15 / 15)      Branches: 87.5% (7 / 8)      Functions: 100% (4 / 4)      Lines: 100% (14 / 14)     

All files » object/ » deepFillIn.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321         1 8       8 9 9 9 20 20 11 9   4           8     1      
define(['./forOwn', '../lang/isPlainObject'], function (forOwn, isPlainObject) {
 
    /**
     * Deeply copy missing properties in the target from the defaults.
     */
    function deepFillIn(target, defaults){
        var i = 0,
            n = arguments.length,
            obj;
 
        while(++i < n) {
            obj = arguments[i];
            Eif (obj) {
                forOwn(obj, function(newValue, key) {
                    var curValue = target[key];
                    if (curValue == null) {
                        target[key] = newValue;
                    } else if (isPlainObject(curValue)
                               && isPlainObject(newValue)) {
                        deepFillIn(curValue, newValue);
                    }
                });
            }
        }
 
        return target;
    }
 
    return deepFillIn;
 
});