1 define(['../lang/isArray', './append'], function (isArray, append) {
4 * Helper function to flatten to a destination array.
5 * Used to remove the need to create intermediate arrays while flattening.
7 function flattenTo(arr, result, level) {
10 } else if (level === 0) {
21 flattenTo(value, result, level - 1);
30 * Recursively flattens an array.
31 * A new array containing all the elements is returned.
32 * If `shallow` is true, it will only flatten one level.
34 function flatten(arr, level) {
35 level = level == null? -1 : level;
36 return flattenTo(arr, [], level);