flat-map

v1.0.0arrow_drop_down
v1.0.0
v0.0.1
STATUS
Passing
DOWNLOADS
29
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
7 years ago
SIZE
501 B
Builds a new collection by applying a function to all elements of this array and using the elements of the resulting collections.
2 contributors
Install flat-map as a package?
Copied
npm i @bit/bit.utils.array.flat-map
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
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 numbers

Pass

#flatMap() should throw a type error in case the first argument is not an array

Pass

#flatMap() should throw a type error in case the second argument is not a function

Pass
Help and resources