1 var arrayPush = require('./_arrayPush'),
2 isArguments = require('./isArguments'),
3 isArray = require('./isArray'),
4 isArrayLikeObject = require('./isArrayLikeObject');
7 * The base implementation of `_.flatten` with support for restricting flattening.
10 * @param {Array} array The array to flatten.
11 * @param {boolean} [isDeep] Specify a deep flatten.
12 * @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
13 * @param {Array} [result=[]] The initial result value.
14 * @returns {Array} Returns the new flattened array.
16 function baseFlatten(array, isDeep, isStrict, result) {
17 result || (result = []);
20 length = array.length;
22 while (++index < length) {
23 var value = array[index];
24 if (isArrayLikeObject(value) &&
25 (isStrict || isArray(value) || isArguments(value))) {
27 // Recursively flatten arrays (susceptible to call stack limits).
28 baseFlatten(value, isDeep, isStrict, result);
30 arrayPush(result, value);
32 } else if (!isStrict) {
33 result[result.length] = value;
39 module.exports = baseFlatten;