(input, shallow, output)
| 5984 | |
| 5985 | // Internal implementation of a recursive `flatten` function. |
| 5986 | var flatten = function(input, shallow, output) { |
| 5987 | each(input, function(value) { |
| 5988 | if (_.isArray(value)) { |
| 5989 | shallow ? push.apply(output, value) : flatten(value, shallow, output); |
| 5990 | } else { |
| 5991 | output.push(value); |
| 5992 | } |
| 5993 | }); |
| 5994 | return output; |
| 5995 | }; |
| 5996 | |
| 5997 | // Return a completely flattened version of an array. |
| 5998 | _.flatten = function(array, shallow) { |