MCPcopy
hub / github.com/requirejs/requirejs / mixin

Function mixin

require.js:109–128  ·  view source on GitHub ↗

* Simple function to mix in properties from source into target, * but only if target does not already have a property of the same name.

(target, source, force, deepStringMixin)

Source from the content-addressed store, hash-verified

107 * but only if target does not already have a property of the same name.
108 */
109 function mixin(target, source, force, deepStringMixin) {
110 if (source) {
111 eachProp(source, function (value, prop) {
112 if (force || !hasProp(target, prop)) {
113 if (deepStringMixin && typeof value === 'object' && value &&
114 !isArray(value) && !isFunction(value) &&
115 !(value instanceof RegExp)) {
116
117 if (!target[prop]) {
118 target[prop] = {};
119 }
120 mixin(target[prop], value, force, deepStringMixin);
121 } else {
122 target[prop] = value;
123 }
124 }
125 });
126 }
127 return target;
128 }
129
130 //Similar to Function.prototype.bind, but the 'this' object is specified
131 //first, since it is easier to read/figure out what 'this' will be.

Callers 1

newContextFunction · 0.85

Calls 4

eachPropFunction · 0.85
hasPropFunction · 0.85
isArrayFunction · 0.85
isFunctionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…