0.1.3 • Published 8 years ago

flat-array v0.1.3

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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