Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

scan

v0.26.1arrow_drop_down
v0.26.1
STATUS
Passing
DOWNLOADS
26
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
A year ago
SIZE
962 B
Scan is similar to [`reduce`](#reduce), but returns a list of successively reduced values from the left
1 contributor
Install scan as a package?
Copied
npm i @bit/ramda.ramda.scan
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
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
const numbers = [1, 2, 3, 4];
  multiply,
  1,
  numbers,
modifieddraft
chevron_left
chevron_right
scan (
fn:Function,
acc:*,
list:Array
) : Array

Scan is similar to reduce, but returns a list of successively reduced values from the left

Example
const numbers = [1, 2, 3, 4];
     const factorials = R.scan(R.multiply, 1, numbers); //=> [1, 1, 2, 6, 24]
Arguments
fn: Function

The iterator function. Receives two values, the accumulator and the current element from the array

acc: *

The accumulator value.

list: Array

The list to iterate over.

Returns
Array

A list of all intermediately reduced values.