mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Correct result of methods that should not return a wrapped value.
This commit is contained in:
@@ -9881,10 +9881,11 @@
|
|||||||
// add `LazyWrapper` functions
|
// add `LazyWrapper` functions
|
||||||
arrayEach(['drop', 'dropRight', 'filter', 'first', 'initial', 'last', 'map', 'rest', 'take', 'takeRight'], function(methodName) {
|
arrayEach(['drop', 'dropRight', 'filter', 'first', 'initial', 'last', 'map', 'rest', 'take', 'takeRight'], function(methodName) {
|
||||||
var func = LazyWrapper.prototype[methodName],
|
var func = LazyWrapper.prototype[methodName],
|
||||||
chainAll = !/^(?:first|last)$/.test(methodName);
|
retWrapped = !/^(?:first|last)$/.test(methodName);
|
||||||
|
|
||||||
lodash.prototype[methodName] = function() {
|
lodash.prototype[methodName] = function() {
|
||||||
var value = this.__wrapped__,
|
var chainAll = this.__chain__,
|
||||||
|
value = this.__wrapped__,
|
||||||
isLazy = value instanceof LazyWrapper;
|
isLazy = value instanceof LazyWrapper;
|
||||||
|
|
||||||
if (!isLazy && !isArray(value)) {
|
if (!isLazy && !isArray(value)) {
|
||||||
@@ -9894,7 +9895,7 @@
|
|||||||
} else {
|
} else {
|
||||||
value = func.apply(isLazy ? value : new LazyWrapper(this), arguments);
|
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;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user