mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Bump to v3.10.0.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
var isArguments = require('../lang/isArguments'),
|
||||
var arrayPush = require('./arrayPush'),
|
||||
isArguments = require('../lang/isArguments'),
|
||||
isArray = require('../lang/isArray'),
|
||||
isArrayLike = require('./isArrayLike'),
|
||||
isObjectLike = require('./isObjectLike');
|
||||
@@ -11,13 +12,14 @@ var isArguments = require('../lang/isArguments'),
|
||||
* @param {Array} array The array to flatten.
|
||||
* @param {boolean} [isDeep] Specify a deep flatten.
|
||||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
|
||||
* @param {Array} [result=[]] The initial result value.
|
||||
* @returns {Array} Returns the new flattened array.
|
||||
*/
|
||||
function baseFlatten(array, isDeep, isStrict) {
|
||||
function baseFlatten(array, isDeep, isStrict, result) {
|
||||
result || (result = []);
|
||||
|
||||
var index = -1,
|
||||
length = array.length,
|
||||
resIndex = -1,
|
||||
result = [];
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
var value = array[index];
|
||||
@@ -25,16 +27,12 @@ function baseFlatten(array, isDeep, isStrict) {
|
||||
(isStrict || isArray(value) || isArguments(value))) {
|
||||
if (isDeep) {
|
||||
// Recursively flatten arrays (susceptible to call stack limits).
|
||||
value = baseFlatten(value, isDeep, isStrict);
|
||||
}
|
||||
var valIndex = -1,
|
||||
valLength = value.length;
|
||||
|
||||
while (++valIndex < valLength) {
|
||||
result[++resIndex] = value[valIndex];
|
||||
baseFlatten(value, isDeep, isStrict, result);
|
||||
} else {
|
||||
arrayPush(result, value);
|
||||
}
|
||||
} else if (!isStrict) {
|
||||
result[++resIndex] = value;
|
||||
result[result.length] = value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user