From 2f9cc91b6420a3d5dfc7c7b7131b2fb6e9449978 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 18 Jun 2014 23:17:46 -0700 Subject: [PATCH] Simplify `_.initial`. --- lodash.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/lodash.js b/lodash.js index 16eab57e1..13c77bb5c 100644 --- a/lodash.js +++ b/lodash.js @@ -3114,22 +3114,9 @@ * _.initial([1, 2, 3]); * // => [1, 2] */ - function initial(array, predicate, thisArg) { + function initial(array) { var length = array ? array.length : 0; - - if (typeof predicate != 'number' && predicate != null) { - var index = length, - n = 0; - - predicate = lodash.callback(predicate, thisArg, 3); - while (index-- && predicate(array[index], index, array)) { - n++; - } - } else { - n = (predicate == null || thisArg) ? 1 : predicate; - } - n = length - (n || 0); - return slice(array, 0, n < 0 ? 0 : n); + return slice(array, 0, length ? length - 1 : 0); } /**