source: frontend/node_modules/underscore/modules/_flatten.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 986 bytes
Line 
1import getLength from './_getLength.js';
2import isArrayLike from './_isArrayLike.js';
3import isArray from './isArray.js';
4import isArguments from './isArguments.js';
5
6// Internal implementation of a recursive `flatten` function.
7export default function flatten(input, depth, strict, output) {
8 output = output || [];
9 if (!depth && depth !== 0) {
10 depth = Infinity;
11 } else if (depth <= 0) {
12 return output.concat(input);
13 }
14 var idx = output.length;
15 for (var i = 0, length = getLength(input); i < length; i++) {
16 var value = input[i];
17 if (isArrayLike(value) && (isArray(value) || isArguments(value))) {
18 // Flatten current level of array or arguments object.
19 if (depth > 1) {
20 flatten(value, depth - 1, strict, output);
21 idx = output.length;
22 } else {
23 var j = 0, len = value.length;
24 while (j < len) output[idx++] = value[j++];
25 }
26 } else if (!strict) {
27 output[idx++] = value;
28 }
29 }
30 return output;
31}
Note: See TracBrowser for help on using the repository browser.