reduce-while
v0.9.6arrow_drop_downv0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
2 KB
Like [`reduce`](#reduce), `reduceWhile` returns a single item by iterating
through the list, successively calling the iterator function.
1 contributor
Like
Install reduce-while as a package?
Copied
npm i @bit/justin-capalbo.ramda.reduce-while
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example modifieddraft
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
and packages in Bit or NPM to the example. any of the 1 million componentstoggle layout
No preview available
chevron_left
chevron_right
reduceWhile (
pred:
Function
,fn:
Function
,a:
*
,list:
) : Array
*
Like reduce
, reduceWhile
returns a single item by iterating
through the list, successively calling the iterator function. reduceWhile
also takes a predicate that is evaluated before each step. If the predicate
returns false
, it “short-circuits” the iteration and returns the current
value of the accumulator.
Example
Arguments
pred:
Function
The predicate. It is passed the accumulator and the current element.
fn:
Function
The iterator function. Receives two values, the accumulator and the current element.
a:
*
The accumulator value.
list:
Array
The list to iterate over.
Returns
*
The final, accumulated value.