scan
Signature - source.ts#L1880
function scan<T, R, I>(
transform: (
previousAccumulatedResult: R | I,
currentValue: T,
currentIndex: number,
) => R,
initialValue: I,
): Operator<T, R>
Calls the specified transform function for all the values pushed by the given source. The return value of the transform function is the accumulated result, and is provided as an argument in the next call to the transform function. The accumulated will be emitted after each Push event.
Parameters
Parameter | Type | Description |
---|---|---|
transform |
| A function that transforms the previousAccumulatedResult (last value returned by this function), the currentValue of the emitted Push event and the currentIndex, and returns an accumulated result. |
initialValue |
| This is used as the initial value to start the accumulation. The first call to the transform function provides this as the previousAccumulatedResult. |