UNPKG

@bookbox/core

Version:

Bookbox — e-book format

17 lines (16 loc) 396 B
export function flatList(elems) { const stack = [elems]; const result = []; while (stack.length) { const current = stack.pop(); if (Array.isArray(current)) { for (let i = current.length - 1; i >= 0; i--) { stack.push(current[i]); } } else { result.push(current); } } return result; }