Cleanup _.mixin.

This commit is contained in:
John-David Dalton
2015-01-02 10:23:16 -06:00
parent 6a87ed2853
commit dff35bc9b7

View File

@@ -10146,30 +10146,31 @@
* // => ['e'] * // => ['e']
*/ */
function mixin(object, source, options) { function mixin(object, source, options) {
var chain = true, if (options == null) {
isObj = isObject(source), var isObj = isObject(source),
noOpts = options == null, props = isObj && keys(source),
props = noOpts && isObj && keys(source), methodNames = props && props.length && baseFunctions(source, props);
methodNames = props && baseFunctions(source, props);
if ((props && props.length && !methodNames.length) || (noOpts && !isObj)) { if (!(methodNames ? methodNames.length : isObj)) {
if (noOpts) { methodNames = false;
options = source; options = source;
source = object;
object = this;
} }
methodNames = false;
source = object;
object = this;
} }
methodNames || (methodNames = baseFunctions(source, keys(source))); if (!methodNames) {
methodNames = baseFunctions(source, keys(source));
}
var chain = true,
index = -1,
isFunc = isFunction(object),
length = methodNames.length;
if (options === false) { if (options === false) {
chain = false; chain = false;
} else if (isObject(options) && 'chain' in options) { } else if (isObject(options) && 'chain' in options) {
chain = options.chain; chain = options.chain;
} }
var index = -1,
isFunc = isFunction(object),
length = methodNames.length;
while (++index < length) { while (++index < length) {
var methodName = methodNames[index]; var methodName = methodNames[index];
object[methodName] = source[methodName]; object[methodName] = source[methodName];