From 4900eae751c112208ae50676fa9866b48efb7538 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 3 Oct 2014 00:14:10 -0700 Subject: [PATCH] Correct result of methods that should not return a wrapped value. --- lodash.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lodash.js b/lodash.js index 105323b27..67047964a 100644 --- a/lodash.js +++ b/lodash.js @@ -9881,10 +9881,11 @@ // add `LazyWrapper` functions arrayEach(['drop', 'dropRight', 'filter', 'first', 'initial', 'last', 'map', 'rest', 'take', 'takeRight'], function(methodName) { var func = LazyWrapper.prototype[methodName], - chainAll = !/^(?:first|last)$/.test(methodName); + retWrapped = !/^(?:first|last)$/.test(methodName); lodash.prototype[methodName] = function() { - var value = this.__wrapped__, + var chainAll = this.__chain__, + value = this.__wrapped__, isLazy = value instanceof LazyWrapper; if (!isLazy && !isArray(value)) { @@ -9894,7 +9895,7 @@ } else { value = func.apply(isLazy ? value : new LazyWrapper(this), arguments); } - return (chainAll || this.__chain__) ? new LodashWrapper(value, true) : value; + return (retWrapped || chainAll) ? new LodashWrapper(value, chainAll) : value; }; });