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
// flattens an array of arbitrarily nested arrays of integers into a flat array of integers | |
const flatten = (values) => values.reduce( | |
// concat single values and recursively flatten any nested arrays | |
(acc, val) => acc.concat(Array.isArray(val) ? flatten(val) : val), [] | |
); | |
export default flatten; |