Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[micro-dash] Flatten fails with large arrays #46

Closed
ersimont opened this issue Jun 26, 2021 · 0 comments
Closed

[micro-dash] Flatten fails with large arrays #46

ersimont opened this issue Jun 26, 2021 · 0 comments

Comments

@ersimont
Copy link
Member

With a large array flatten() fails with a stack overflow error.

A (much bigger) implementation that works:

function flatten(array: any[]) {
  const result: any[] = [];
  for (const element of array) {
    if (Array.isArray(element)) {
      for (const inner of element) {
        result.push(inner);
      }
    } else {
      result.push(element);
    }
  }
  return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant