Fix lazy methods to execute non-lazy methods performed in between.

This commit is contained in:
Filip Zawada
2014-11-20 14:59:45 +01:00
committed by John-David Dalton
parent 7cf40576dd
commit 8612946bf5
2 changed files with 11 additions and 1 deletions

View File

@@ -10266,7 +10266,7 @@
: lodash[methodName](this.value());
}
if (isLazy || isArray(value)) {
var result = func.apply(isLazy ? value : new LazyWrapper(this), args);
var result = func.apply(isLazy && !this.__queue__.length ? value : new LazyWrapper(this), args);
return new LodashWrapper(result, chainAll);
}
return this.thru(function(value) {

View File

@@ -1894,6 +1894,16 @@
deepEqual(_.compact(falsey.concat(array)), array);
});
test('should filter falsey values when in between lazy operators', 1, function () {
if (!isNpm) {
var wrapped = _(falsey).map(_.identity).compact().map(_.identity);
deepEqual(wrapped.value(), []);
}
else {
skipTest(2);
}
});
test('should return a wrapped value when chaining', 2, function() {
if (!isNpm) {
var wrapped = _(falsey).compact();