From 3aa40d4df64c27fb71bf8c0cd2ee4b336ddd9d31 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 1 Mar 2015 01:22:00 -0800 Subject: [PATCH] Simplify `baseFlatten` and always provide a `fromIndex`. --- lodash.src.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index b7c00fc2b..cecf66386 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -2144,13 +2144,13 @@ * * @private * @param {Array} array The array to flatten. - * @param {boolean} [isDeep] Specify a deep flatten. - * @param {boolean} [isStrict] Restrict flattening to arrays and `arguments` objects. - * @param {number} [fromIndex=0] The index to start from. + * @param {boolean} isDeep Specify a deep flatten. + * @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects. + * @param {number} fromIndex The index to start from. * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, isDeep, isStrict, fromIndex) { - var index = fromIndex == null ? -1 : (fromIndex - 1), + var index = fromIndex - 1, length = array.length, resIndex = -1, result = []; @@ -2161,7 +2161,7 @@ if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) { if (isDeep) { // Recursively flatten arrays (susceptible to call stack limits). - value = baseFlatten(value, isDeep, isStrict); + value = baseFlatten(value, isDeep, isStrict, 0); } var valIndex = -1, valLength = value.length; @@ -4666,7 +4666,7 @@ if (guard && isIterateeCall(array, isDeep, guard)) { isDeep = false; } - return length ? baseFlatten(array, isDeep) : []; + return length ? baseFlatten(array, isDeep, false, 0) : []; } /** @@ -4684,7 +4684,7 @@ */ function flattenDeep(array) { var length = array ? array.length : 0; - return length ? baseFlatten(array, true) : []; + return length ? baseFlatten(array, true, false, 0) : []; } /** @@ -5344,7 +5344,7 @@ * // => [1, 2, 4] */ function union() { - return baseUniq(baseFlatten(arguments, false, true)); + return baseUniq(baseFlatten(arguments, false, true, 0)); } /**