Share your code. Components are building blocks, you are the architect.

utils/split-when
v1.1.0
1.1.0
1.0.0
MIT
PUBLIC
3
1     DEPENDENCIES
Build: fail
BuildFail
Build Status: fail
Takes a list and a predicate and returns a pair of lists with the following properties:

Please configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Use utils/split-when in your project
npm i @bit/bit.ramda.utils.split-when
Copied

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