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

utils/take-while
v1.1.0
1.1.0
1.0.0
MIT
PUBLIC
3
Build: fail
BuildFail
Build Status: fail
Returns a new list containing the first `n` elements of a given list,

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/take-while in your project
npm i @bit/bit.ramda.utils.take-while
Copied

takeWhile (fn:Function, xs:Array) : Array

Returns a new list containing the first n elements of a given list, passing each value to the supplied predicate function, and terminating when the predicate function returns false. Excludes the element that caused the predicate function to fail. The predicate function is passed one argument: (value).

Dispatches to the takeWhile method of the second argument, if present.

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

Example

var isNotFour = x => x !== 4;

     R.takeWhile(isNotFour, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3]

     R.takeWhile(x => x !== 'd' , 'Ramda'); //=> 'Ram'

Arguments

fn: Function

The function called per iteration.

xs: Array

The collection to iterate over.

Returns

Array

A new array.