mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Simplify lazy filter, map, & takeWhile assignment.
This commit is contained in:
@@ -11429,15 +11429,13 @@
|
|||||||
|
|
||||||
// Add `LazyWrapper` methods that accept an `iteratee` value.
|
// Add `LazyWrapper` methods that accept an `iteratee` value.
|
||||||
arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
|
arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
|
||||||
var isFilter = index == LAZY_FILTER_FLAG,
|
var isFilter = index == LAZY_FILTER_FLAG || index == LAZY_WHILE_FLAG;
|
||||||
isWhile = index == LAZY_WHILE_FLAG;
|
|
||||||
|
|
||||||
LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
|
LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
|
||||||
var result = this.clone(),
|
var result = this.clone(),
|
||||||
filtered = result.__filtered__,
|
|
||||||
iteratees = result.__iteratees__ || (result.__iteratees__ = []);
|
iteratees = result.__iteratees__ || (result.__iteratees__ = []);
|
||||||
|
|
||||||
result.__filtered__ = filtered || isFilter || isWhile;
|
result.__filtered__ = result.__filtered__ || isFilter;
|
||||||
iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 3), 'type': index });
|
iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 3), 'type': index });
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user