Cleanup _.dropRightWhile and _.takeRightWhile.

This commit is contained in:
John-David Dalton
2014-10-30 23:44:19 -07:00
parent 6dd8c05533
commit dd70fcb9bc

View File

@@ -3507,12 +3507,11 @@
* // => ['barney', 'fred'] * // => ['barney', 'fred']
*/ */
function dropRightWhile(array, predicate, thisArg) { function dropRightWhile(array, predicate, thisArg) {
var length = array ? array.length : 0, var length = array ? array.length : 0;
index = length;
predicate = getCallback(predicate, thisArg, 3); predicate = getCallback(predicate, thisArg, 3);
while (index-- && predicate(array[index], index, array)) {} while (length-- && predicate(array[length], length, array)) {}
return slice(array, 0, index + 1); return slice(array, 0, length + 1);
} }
/** /**
@@ -4293,12 +4292,11 @@
* // => ['pebbles'] * // => ['pebbles']
*/ */
function takeRightWhile(array, predicate, thisArg) { function takeRightWhile(array, predicate, thisArg) {
var length = array ? array.length : 0, var length = array ? array.length : 0;
index = length;
predicate = getCallback(predicate, thisArg, 3); predicate = getCallback(predicate, thisArg, 3);
while (index-- && predicate(array[index], index, array)) {} while (length-- && predicate(array[length], length, array)) {}
return slice(array, index + 1); return slice(array, length + 1);
} }
/** /**