mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Fix broken lazy reverse
This commit is contained in:
@@ -4982,6 +4982,12 @@
|
|||||||
* // => [3, 2, 1]
|
* // => [3, 2, 1]
|
||||||
*/
|
*/
|
||||||
function wrapperReverse() {
|
function wrapperReverse() {
|
||||||
|
var wrapped = this.__wrapped__;
|
||||||
|
|
||||||
|
if(wrapped instanceof LazyWrapper) {
|
||||||
|
return wrapped.reverse();
|
||||||
|
}
|
||||||
|
|
||||||
return this.thru(function(value) {
|
return this.thru(function(value) {
|
||||||
return value.reverse();
|
return value.reverse();
|
||||||
});
|
});
|
||||||
|
|||||||
21
test/test.js
21
test/test.js
@@ -12941,6 +12941,27 @@
|
|||||||
skipTest(2);
|
skipTest(2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test('should be lazy when in a lazy chain sequence', 1, function() {
|
||||||
|
if (!isNpm) {
|
||||||
|
var spy = {
|
||||||
|
toString: function () {
|
||||||
|
throw new Error("Spy was revealed");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var actual = _(["a", spy])
|
||||||
|
.map(String)
|
||||||
|
.reverse()
|
||||||
|
.last();
|
||||||
|
|
||||||
|
strictEqual(actual, "a");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user