Gravatar for undefined
0 Likes

Builds a new collection by applying a function to all elements of

bit import bit.utils/array/flat-map

flatMap (array:[*], cb:Function) : [*]

Builds a new collection by applying a function to all elements of this array and using the elements of the resulting collections.

Example

flatMap([[1, 2, 3], [4, 5, 6]], val => val) // => [1, 2, 3, 4, 5, 6]

Arguments

array: [*]

cb: Function

Returns

[*]

Test Summary

#flatMap() should flatten the multi-dimensional array to a single-dimensional one Pass
#flatMap() should flatten to a single-dimensional array without odd numbersPass
#flatMap() should throw a type error in case the first argument is not an arrayPass
#flatMap() should throw a type error in case the second argument is not a functionPass