source: node_modules/ramda/es/internal/_makeFlat.js

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: 740 bytes
Line 
1import _isArrayLike from "./_isArrayLike.js";
2/**
3 * `_makeFlat` is a helper function that returns a one-level or fully recursive
4 * function based on the flag passed in.
5 *
6 * @private
7 */
8
9export default function _makeFlat(recursive) {
10 return function flatt(list) {
11 var value, jlen, j;
12 var result = [];
13 var idx = 0;
14 var ilen = list.length;
15
16 while (idx < ilen) {
17 if (_isArrayLike(list[idx])) {
18 value = recursive ? flatt(list[idx]) : list[idx];
19 j = 0;
20 jlen = value.length;
21
22 while (j < jlen) {
23 result[result.length] = value[j];
24 j += 1;
25 }
26 } else {
27 result[result.length] = list[idx];
28 }
29
30 idx += 1;
31 }
32
33 return result;
34 };
35}
Note: See TracBrowser for help on using the repository browser.