-
Notifications
You must be signed in to change notification settings - Fork 11
/
mixIn.js
29 lines (26 loc) · 817 Bytes
/
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
29
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.
* @version 0.1.4 (2012/10/29)
*/
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;
});