Skip to content
Buy me a coffee

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.

  • Iterable<T>

T

S extends BaseStream<T, S>

[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.

void


[iterator](): Iterator<T, any, any>

Defined in: site/node_modules/typescript/lib/lib.es2015.iterable.d.ts:47

Iterator<T, any, any>

Iterable.[iterator]


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.

void


isParallel(): boolean

Defined in: src/stream/Stream.ts:44

Returns true if parallel() was requested. It only reports the flag; evaluation is always sequential.

boolean


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.

Iterator<T>

IllegalStateException if the stream was already operated upon or closed


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.

() => void

S

IllegalStateException if the stream was already operated upon or closed

NullPointerException if closeHandler is null


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.

S


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.

S


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.

Spliterator<T>

IllegalStateException if the stream was already operated upon or closed


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.

S

IllegalStateException if the stream was already operated upon or closed