main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
772 bytes
|
Line | |
---|
1 | var _isArrayLike =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./_isArrayLike.js");
|
---|
4 | /**
|
---|
5 | * `_makeFlat` is a helper function that returns a one-level or fully recursive
|
---|
6 | * function based on the flag passed in.
|
---|
7 | *
|
---|
8 | * @private
|
---|
9 | */
|
---|
10 |
|
---|
11 |
|
---|
12 | function _makeFlat(recursive) {
|
---|
13 | return function flatt(list) {
|
---|
14 | var value, jlen, j;
|
---|
15 | var result = [];
|
---|
16 | var idx = 0;
|
---|
17 | var ilen = list.length;
|
---|
18 |
|
---|
19 | while (idx < ilen) {
|
---|
20 | if (_isArrayLike(list[idx])) {
|
---|
21 | value = recursive ? flatt(list[idx]) : list[idx];
|
---|
22 | j = 0;
|
---|
23 | jlen = value.length;
|
---|
24 |
|
---|
25 | while (j < jlen) {
|
---|
26 | result[result.length] = value[j];
|
---|
27 | j += 1;
|
---|
28 | }
|
---|
29 | } else {
|
---|
30 | result[result.length] = list[idx];
|
---|
31 | }
|
---|
32 |
|
---|
33 | idx += 1;
|
---|
34 | }
|
---|
35 |
|
---|
36 | return result;
|
---|
37 | };
|
---|
38 | }
|
---|
39 |
|
---|
40 | module.exports = _makeFlat; |
---|
Note:
See
TracBrowser
for help on using the repository browser.