Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

flat-map

v1.0.0arrow_drop_down
v1.0.0
v0.0.1
STATUS
Passing
DOWNLOADS
29
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
2 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
Use flat-map in your project ?
Copied
npm i @bit/bit.utils.array.flat-map
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
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';
revert changes
reload
toggle layout
maximize
flatMap(
  [[1, 2, 3], [4, 5, 6]],
  val => val
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