Created
May 1, 2016 07:02
-
-
Save albertorestifo/55455e43b2056f1603657a2bc0b2fed0 to your computer and use it in GitHub Desktop.
Multi-level flatten function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var flatten = arr => arr.reduce((p, c) => p.concat(Array.isArray(c) ? flatten(c) : c), []); | |
/** | |
* Credit goes to Benjamin Gruenbaum, from his comment on this article: http://www.2ality.com/2016/04/promise-trees.html | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment