/**
* Flatten the given array into a single array of elements.
* The given array can be composed of multiple depths of objects and or arrays.
* @param {Array} array - array to flatten
* @returns {Array} a flat array with a single list of elements
* @alias module:array-utils.flatten
* @example
* const flat = flatten([[1], [2, 3, [4, 5]], 6]) // returns [1, 2, 3, 4, 5, 6]
*/
const flatten = (arr) => arr.reduce((acc, val) => Array.isArray(val) ? acc.concat(flatten(val)) : acc.concat(val), [])
module.exports = flatten