Generalize the unwrapped value path in lazy method wrappers a bit.

This commit is contained in:
John-David Dalton
2015-07-12 10:08:57 -07:00
parent 56452d9fd8
commit 974306d4f0

View File

@@ -11680,9 +11680,8 @@
isLazy = useLazy = false; isLazy = useLazy = false;
} }
var interceptor = function(value) { var interceptor = function(value) {
return (retUnwrapped && chainAll) var result = lodashFunc.apply(lodash, arrayPush([value], args));
? lodashFunc(value, 1)[0] return (retUnwrapped && chainAll) ? result[0] : result;
: lodashFunc.apply(undefined, arrayPush([value], args));
}; };
var action = { 'func': thru, 'args': [interceptor], 'thisArg': undefined }, var action = { 'func': thru, 'args': [interceptor], 'thisArg': undefined },
@@ -11692,13 +11691,14 @@
if (onlyLazy) { if (onlyLazy) {
value = value.clone(); value = value.clone();
value.__actions__.push(action); value.__actions__.push(action);
return func.call(value); return func.apply(this, args);
} }
return lodashFunc.call(undefined, this.value())[0]; var result = lodashFunc.apply(lodash, arrayPush([this.value()], args));
return result[0];
} }
if (!retUnwrapped && useLazy) { if (!retUnwrapped && useLazy) {
value = onlyLazy ? value : new LazyWrapper(this); value = onlyLazy ? value : new LazyWrapper(this);
var result = func.apply(value, args); result = func.apply(value, args);
result.__actions__.push(action); result.__actions__.push(action);
return new LodashWrapper(result, chainAll); return new LodashWrapper(result, chainAll);
} }