flat-array

0.1.3 • Public • Published

array flatten

XO code style

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

Package Sidebar

Install

npm i flat-array

Weekly Downloads

6

Version

0.1.3

License

MIT

Last publish

Collaborators

  • gillchristian