Gatherers
constGatherers:object
Defined in: src/stream/Gatherers.ts:304
Built-in Gatherers for stream.gather. All are sequential (default combiner).
Type Declaration
Section titled “Type Declaration”fold()
Section titled “fold()”fold<
T,R>(initial,folder):DefinedGatherer<T,Acc<R>,R>
Returns a gatherer that folds the elements, in order, into one value starting from initial() and emits it at
the end of input; an empty stream emits initial().
Type Parameters
Section titled “Type Parameters”T
R
Parameters
Section titled “Parameters”initial
Section titled “initial”() => R
folder
Section titled “folder”(acc, element) => R
Returns
Section titled “Returns”DefinedGatherer<T, Acc<R>, R>
Throws
Section titled “Throws”NullPointerException if initial or folder is null
mapConcurrent()
Section titled “mapConcurrent()”mapConcurrent<
T,R>(maxConcurrency,mapper):DefinedGatherer<T,null,R>
Returns a gatherer that maps each element, preserving encounter order. The mapper runs synchronously, one
element at a time; maxConcurrency is validated but has no further effect. A mapper exception is rethrown as-is
when it is a RuntimeException, otherwise wrapped in a RuntimeException with it as cause. The mapper is not
called once the downstream is rejecting. Promises are not awaited.
Type Parameters
Section titled “Type Parameters”T
R
Parameters
Section titled “Parameters”maxConcurrency
Section titled “maxConcurrency”number
mapper
Section titled “mapper”(element) => R
Returns
Section titled “Returns”DefinedGatherer<T, null, R>
Throws
Section titled “Throws”IllegalArgumentException if maxConcurrency is less than 1 (or not an integer)
Throws
Section titled “Throws”NullPointerException if mapper is null
scan()
Section titled “scan()”scan<
T,R>(initial,scanner):DefinedGatherer<T,Acc<R>,R>
Returns a gatherer that emits every running accumulation: scanner(current, element) for each element, starting
from initial() (which itself is not emitted).
Type Parameters
Section titled “Type Parameters”T
R
Parameters
Section titled “Parameters”initial
Section titled “initial”() => R
scanner
Section titled “scanner”(acc, element) => R
Returns
Section titled “Returns”DefinedGatherer<T, Acc<R>, R>
Throws
Section titled “Throws”NullPointerException if initial or scanner is null
windowFixed()
Section titled “windowFixed()”windowFixed<
T>(windowSize):DefinedGatherer<T,Window<T>,List<T>>
Returns a gatherer that groups elements into consecutive unmodifiable lists of windowSize; the last window may
be shorter. No window for empty input.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”windowSize
Section titled “windowSize”number
Returns
Section titled “Returns”DefinedGatherer<T, Window<T>, List<T>>
Throws
Section titled “Throws”IllegalArgumentException if windowSize is less than 1 (or not an integer)
windowSliding()
Section titled “windowSliding()”windowSliding<
T>(windowSize):DefinedGatherer<T,Window<T>,List<T>>
Returns a gatherer of sliding unmodifiable windows of windowSize, each dropping the oldest element of the
previous one. With fewer elements than windowSize, one window holding all of them; none for empty input.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”windowSize
Section titled “windowSize”number
Returns
Section titled “Returns”DefinedGatherer<T, Window<T>, List<T>>
Throws
Section titled “Throws”IllegalArgumentException if windowSize is less than 1 (or not an integer)