swc/crates/swc_bundler/tests/.cache/deno/647032f84ece50f5a38babe73ea199ac6ee4c396.ts
2021-11-09 20:42:49 +09:00

37 lines
819 B
TypeScript

// Loaded from https://deno.land/x/ramda@v0.27.2/source/internal/_makeFlat.js
import _isArrayLike from './_isArrayLike.js';
/**
* `_makeFlat` is a helper function that returns a one-level or fully recursive
* function based on the flag passed in.
*
* @private
*/
export default function _makeFlat(recursive) {
return function flatt(list) {
var value, jlen, j;
var result = [];
var idx = 0;
var ilen = list.length;
while (idx < ilen) {
if (_isArrayLike(list[idx])) {
value = recursive ? flatt(list[idx]) : list[idx];
j = 0;
jlen = value.length;
while (j < jlen) {
result[result.length] = value[j];
j += 1;
}
} else {
result[result.length] = list[idx];
}
idx += 1;
}
return result;
};
}