Code coverage report for object/mixIn.js

Statements: 100% (12 / 12)      Branches: 100% (2 / 2)      Functions: 100% (4 / 4)      Lines: 100% (11 / 11)     

All files » object/ » mixIn.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 291                 1 11     11 17 17 13     11     1 22     1    
define(['./forOwn'], function(forOwn){
 
    /**
    * Combine properties from all the objects into first one.
    * - This method affects target object in place, if you want to create a new Object pass an empty object as first param.
    * @param {object} target    Target Object
    * @param {...object} objects    Objects to be combined (0...n objects).
    * @return {object} Target Object.
    */
    function mixIn(target, objects){
        var i = 0,
            n = arguments.length,
            obj;
        while(++i < n){
            obj = arguments[i];
            if (obj != null) {
                forOwn(obj, copyProp, target);
            }
        }
        return target;
    }
 
    function copyProp(val, key){
        this[key] = val;
    }
 
    return mixIn;
});