BaseStream
Defined in: src/stream/Stream.ts:29
Behaviour shared by every stream: iteration, the parallel flag, ordering and closing.
A stream is single use. Once an intermediate or terminal operation has been called on a stream object, any
further operation on it throws IllegalStateException; only close(), isParallel(), parallel() and
sequential() stay callable. parallel() only records a flag: evaluation is always sequential (one JS thread),
which every parallel-capable operation is specified to tolerate. Streams are also JS iterables: for…of and
spread consume the stream like iterator() and close it when the iteration ends.
Extends
Section titled “Extends”Iterable<T>
Type Parameters
Section titled “Type Parameters”T
S extends BaseStream<T, S>
Methods
Section titled “Methods”[dispose]()
Section titled “[dispose]()”[dispose]():
void
Defined in: src/stream/Stream.ts:71
Calls close(), so using s = ... closes the stream at the end of the block. Present where the runtime has Symbol.dispose.
Returns
Section titled “Returns”void
[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<T,any,any>
Defined in: site/node_modules/typescript/lib/lib.es2015.iterable.d.ts:47
Returns
Section titled “Returns”Iterator<T, any, any>
Inherited from
Section titled “Inherited from”Iterable.[iterator]
close()
Section titled “close()”close():
void
Defined in: src/stream/Stream.ts:69
Closes the stream and runs its close handlers once, in registration order. If handlers throw, the rest still
run and the first error is rethrown with later ones attached via suppressed. A terminal operation does not
close the stream; closing a closed stream does nothing.
Returns
Section titled “Returns”void
isParallel()
Section titled “isParallel()”isParallel():
boolean
Defined in: src/stream/Stream.ts:44
Returns true if parallel() was requested. It only reports the flag; evaluation is always sequential.
Returns
Section titled “Returns”boolean
iterator()
Section titled “iterator()”iterator():
Iterator<T>
Defined in: src/stream/Stream.ts:35
Returns an Iterator over the stream’s elements. This is a terminal operation; elements are pulled
through the stages lazily, as hasNext()/next() ask for them. Unlike for…of, it does not close the stream.
Returns
Section titled “Returns”Iterator<T>
Throws
Section titled “Throws”IllegalStateException if the stream was already operated upon or closed
onClose()
Section titled “onClose()”onClose(
closeHandler):S
Defined in: src/stream/Stream.ts:63
Registers a handler run by close() and returns this same stream; handlers run in registration order.
Parameters
Section titled “Parameters”closeHandler
Section titled “closeHandler”() => void
Returns
Section titled “Returns”S
Throws
Section titled “Throws”IllegalStateException if the stream was already operated upon or closed
Throws
Section titled “Throws”NullPointerException if closeHandler is null
parallel()
Section titled “parallel()”parallel():
S
Defined in: src/stream/Stream.ts:51
Sets the parallel flag and returns this same stream. Evaluation stays sequential on the single JS thread;
code written for parallel streams (associative reducers, combiners, findAny) gives the same results.
Returns
Section titled “Returns”S
sequential()
Section titled “sequential()”sequential():
S
Defined in: src/stream/Stream.ts:46
Clears the parallel flag and returns this same stream. Allowed on a stream that was already used.
Returns
Section titled “Returns”S
spliterator()
Section titled “spliterator()”spliterator():
Spliterator<T>
Defined in: src/stream/Stream.ts:42
Returns a Spliterator over the stream’s elements; a terminal operation that pulls elements lazily. It reports the pipeline’s characteristics (ORDERED, DISTINCT, SORTED, SIZED / SUBSIZED as the stages keep them); with no stages it is the source spliterator itself.
Returns
Section titled “Returns”Spliterator<T>
Throws
Section titled “Throws”IllegalStateException if the stream was already operated upon or closed
unordered()
Section titled “unordered()”unordered():
S
Defined in: src/stream/Stream.ts:57
Returns an equivalent stream without the encounter-order constraint (an intermediate operation), or this stream itself when it is already unordered. Evaluation is sequential, so elements still arrive in source order.
Returns
Section titled “Returns”S
Throws
Section titled “Throws”IllegalStateException if the stream was already operated upon or closed