The problem with the current implementation is that it's prone to stack overflow ("Maximum call stack size exceeded") as the spread operator puts all arguments on stack.
I'd suggest changing it to a less fancy but more stable implementation:
const flatten = (array) => {
let dest = [];
const len = array.length
for(let i = 0; i < len; i++){
dest.push(...array[i])
}
return dest;
};
Given
flatten
function from utils.js:The problem with the current implementation is that it's prone to stack overflow ("Maximum call stack size exceeded") as the spread operator puts all arguments on stack.
I'd suggest changing it to a less fancy but more stable implementation: