flat-array
v0.1.3
Published
Flatten an array
Downloads
24
Maintainers
Readme
array flatten
Just a simple function to flatten an Array. Works well in both, the browser & node.
install
npm i -S flat-array
and use it
import flattenArray from 'flat-array'
// OR
const flattenArray = require('flat-array')
const abcde = flattenArray(['a', ['b', 'c'], 'd', ['e']])
console.log(abcde) // ['a', 'b', 'c', 'd', 'e']
// NOTE: the result is shadow flatted, only the first lvl arrays are flattened
const fooBar = flattenArray(['f', ['o', 'o'], ['b', ['a', 'r']]])
console.log(fooBar) // ['f', 'o', 'o', 'b', ['a', 'r']]
behavior
flattenArray
is a pure function, it does not mutate the provided array.
FAQ
- Why such small module?: Sindre gives a good answer to this.