/array_flatten

Function makes array flatten, converts all sub-arrays into one level array. Inspired by one little function from https://github.com/andris9/hoodiecrow/

Primary LanguageJavaScriptMIT LicenseMIT

array_flatten

Converts all sub-arrays into one level array

array_flatten([1,[2,3]]) -> [1,2,3]

If you specified not necessary param level, then function will be limited. For example:

array_flatten([1,[2,[3,[4]]]], 2) -> [1,2,3,[4]]

array_flatten([1,[[2]],[3],[[4]]], 1) -> [1,[2],3,[4]]

array_flatten([1,[[2],[3],[[4]]]], 0) -> [1,[[2],[3],[[4]]]]

To install by npm:

npm install -g array_flatten