chain

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
5
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
3 KB
`chain` maps a function over a list and concatenates the results.
1 contributor
Install chain as a package?
Copied
npm i @bit/justin-capalbo.ramda.chain
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
chain (
fn:Function,
list:Array
) : Array

chain maps a function over a list and concatenates the results. chain is also known as flatMap in some libraries.

Dispatches to the chain method of the second argument, if present, according to the FantasyLand Chain spec.

If second argument is a function, chain(f, g)(x) is equivalent to f(g(x), x).

Acts as a transducer if a transformer is given in list position.

Example
const duplicate = n => [n, n];
     R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3]

     R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1]
Arguments
fn: Function

The function to map with

list: Array

The list to map over

Returns
Array

The result of flat-mapping `list` with `fn`

Help and resources