split-when

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
851 B
Takes a list and a predicate and returns a pair of lists with the following properties:
1 contributor
Install split-when as a package?
Copied
npm i @bit/justin-capalbo.ramda.split-when
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
splitWhen (
pred:Function,
list:Array
) : Array

Takes a list and a predicate and returns a pair of lists with the following properties:

  • the result of concatenating the two output lists is equivalent to the input list;
  • none of the elements of the first output list satisfies the predicate; and
  • if the second output list is non-empty, its first element satisfies the predicate.
Example
R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]);   //=> [[1], [2, 3, 1, 2, 3]]
Arguments
pred: Function

The predicate that determines where the array is split.

list: Array

The array to be split.

Returns
Array

Help and resources