mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Simplify _.*RightWhile loops
This commit is contained in:
committed by
John-David Dalton
parent
b291dcadc6
commit
1241fb54f3
18
lodash.js
18
lodash.js
@@ -2884,14 +2884,11 @@
|
|||||||
*/
|
*/
|
||||||
function dropRightWhile(array, predicate, thisArg) {
|
function dropRightWhile(array, predicate, thisArg) {
|
||||||
var length = array ? array.length : 0,
|
var length = array ? array.length : 0,
|
||||||
index = length,
|
index = length;
|
||||||
n = 0;
|
|
||||||
|
|
||||||
predicate = lodash.callback(predicate, thisArg, 3);
|
predicate = lodash.callback(predicate, thisArg, 3);
|
||||||
while (index-- && predicate(array[index], index, array)) {
|
while (index-- && predicate(array[index], index, array)) { }
|
||||||
n++;
|
return slice(array, 0, index + 1);
|
||||||
}
|
|
||||||
return slice(array, 0, length - n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3606,14 +3603,11 @@
|
|||||||
*/
|
*/
|
||||||
function takeRightWhile(array, predicate, thisArg) {
|
function takeRightWhile(array, predicate, thisArg) {
|
||||||
var length = array ? array.length : 0,
|
var length = array ? array.length : 0,
|
||||||
index = length,
|
index = length;
|
||||||
n = 0;
|
|
||||||
|
|
||||||
predicate = lodash.callback(predicate, thisArg, 3);
|
predicate = lodash.callback(predicate, thisArg, 3);
|
||||||
while (index-- && predicate(array[index], index, array)) {
|
while (index-- && predicate(array[index], index, array)) { }
|
||||||
n++;
|
return slice(array, index + 1);
|
||||||
}
|
|
||||||
return slice(array, length - n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user