* 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)
| 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. |
no test coverage detected
searching dependent graphs…