A lazy, pull-based, resource-safe sequence of elements of type A that may fail with an error of type E.
A Stream is a ''description'': nothing executes until a terminal operation is driven. Cross-platform terminals such as runAsync, runCollectAsync, and headAsync return Async[Either[E, Z]]. The JVM additionally provides blocking terminals such as run, runCollect, and head, which return Either[E, Z]. Left contains typed stream errors; defects fail the outer Async or propagate from a JVM blocking terminal.
Type parameters
- A
-
Element type.
- E
-
Error type.
Attributes
- Companion
- object
- Source
- Stream.scala
- Graph
-
- Supertypes
Members list
Value members
Abstract methods
Renders this stream as a human-readable description of its pipeline.
Concrete methods
Zips this stream with that, pairing elements positionally. Shorter stream determines length. Uses zio.blocks.combinators.Tuples for flattened composition: a && b && c produces a Stream of (A, B, C).
Zips this stream with that, pairing elements positionally. Shorter stream determines length. Uses zio.blocks.combinators.Tuples for flattened composition: a && b && c produces a Stream of (A, B, C).
Attributes
- Source
- Stream.scala
Alias for concat.
Decouples upstream production from downstream consumption with a bounded buffer of n elements while preserving order. n must be at least one. Failure, downstream close, or cancellation closes the producer.
Decouples upstream production from downstream consumption with a bounded buffer of n elements while preserving order. n must be at least one. Failure, downstream close, or cancellation closes the producer.
Attributes
- Source
- Stream.scala
On the first typed error, closes the failing stream and lazily switches to the stream returned by f. Defects are not handled.
On the first typed error, closes the failing stream and lazily switches to the stream returned by f. Defects are not handled.
Attributes
- Source
- Stream.scala
On the first non-fatal defect matched by f, closes the failing stream and lazily switches to the selected stream. Typed errors and unmatched defects are not handled.
On the first non-fatal defect matched by f, closes the failing stream and lazily switches to the selected stream. Typed errors and unmatched defects are not handled.
Attributes
- Source
- Stream.scala
Groups elements into Chunks of size n, preserving order. The final group may be smaller; n must be at least one.
Groups elements into Chunks of size n, preserving order. The final group may be smaller; n must be at least one.
Attributes
- Source
- Stream.scala
Applies a partial function, emitting only defined results.
Asynchronously transforms defined elements, dropping None results.
Emits all elements of this followed by all elements of that.
Asynchronously counts the number of elements.
Emits the first occurrence of each element, preserving order. Distinctness state is allocated per materialization and may grow without bound.
Emits the first occurrence of each element, preserving order. Distinctness state is allocated per materialization and may grow without bound.
Attributes
- Source
- Stream.scala
Emits the first element for each key computed by f, preserving order. Key state is allocated per materialization and may grow without bound.
Emits the first element for each key computed by f, preserving order. Key state is allocated per materialization and may grow without bound.
Attributes
- Source
- Stream.scala
Sequentially computes keys and emits the first element for each key, preserving order. Key state is per materialization and may grow without bound; asynchronous failures are defects.
Sequentially computes keys and emits the first element for each key, preserving order. Key state is per materialization and may grow without bound; asynchronous failures are defects.
Attributes
- Source
- Stream.scala
Skips the first n elements, then emits the rest. n <= 0 is a no-op.
Skips the first n elements, then emits the rest. n <= 0 is a no-op.
Attributes
- Source
- Stream.scala
Registers finalizer lazily and runs it exactly once when the materialized stream closes, including normal completion, failure, early termination, and cancellation. A finalizer exception is a defect.
Registers finalizer lazily and runs it exactly once when the materialized stream closes, including normal completion, failure, early termination, and cancellation. A finalizer exception is a defect.
Attributes
- Source
- Stream.scala
Registers an asynchronous finalizer lazily and awaits it exactly once when the materialized stream closes, including normal completion, failure, early termination, and cancellation. Finalizer failure is a defect.
Registers an asynchronous finalizer lazily and awaits it exactly once when the materialized stream closes, including normal completion, failure, early termination, and cancellation. Finalizer failure is a defect.
Attributes
- Source
- Stream.scala
Asynchronously tests whether any element satisfies pred.
Emits only elements satisfying pred.
Tests elements sequentially and emits those satisfying the asynchronous predicate, preserving order. Predicate failure is a defect.
Tests elements sequentially and emits those satisfying the asynchronous predicate, preserving order. Predicate failure is a defect.
Attributes
- Source
- Stream.scala
Asynchronously returns the first element satisfying pred, or None.
Maps each element to an inner stream and consumes those streams sequentially in input order, closing each before advancing to the next.
Maps each element to an inner stream and consumes those streams sequentially in input order, closing each before advancing to the next.
Attributes
- Source
- Stream.scala
Applies f to each element to produce an inner stream, then merges up to n inner streams concurrently. Output is unordered (arrival order, not input order). On JVM, each inner stream runs on a virtual thread. On JS, degrades to sequential flatMap. n must be at least one. Failure or cancellation closes the outer stream and all active inner streams.
Applies f to each element to produce an inner stream, then merges up to n inner streams concurrently. Output is unordered (arrival order, not input order). On JVM, each inner stream runs on a virtual thread. On JS, degrades to sequential flatMap. n must be at least one. Failure or cancellation closes the outer stream and all active inner streams.
Attributes
- Source
- Stream.scala
Asynchronously tests whether all elements satisfy pred.
Alias for runForeachAsync.
Alias for chunked. Matches upstream naming.
Asynchronously returns the first element, or None if empty.
Inserts sep between each pair of consecutive elements.
Returns the underlying Chunk if this stream wraps a known, materialized chunk, None otherwise. O(1).
Returns the underlying Chunk if this stream wraps a known, materialized chunk, None otherwise. O(1).
Only streams created via Stream.fromChunk, Stream.fromArray, or Stream.empty return Some. All combinators (map, filter, take, drop, concat, etc.) return None because the chunk identity is lost after transformation.
Attributes
- Source
- Stream.scala
Returns the number of elements if known without consuming the stream, None otherwise. O(1).
Returns the number of elements if known without consuming the stream, None otherwise. O(1).
Element-preserving combinators like map propagate the count. Element-filtering combinators like filter invalidate it.
Attributes
- Source
- Stream.scala
Asynchronously returns the last element, or None if empty.
Lazily transforms each element with f, preserving order.
Lazily transforms each element with f, preserving order.
Transforms elements with a stateful function f, threading state S through each step and emitting the B from each result.
Transforms elements with a stateful function f, threading state S through each step and emitting the B from each result.
Value parameters
- f
-
Function that takes the current state and an element, returning the updated state and the output element.
- init
-
Initial state value.
Attributes
- Source
- Stream.scala
Asynchronously transforms elements while threading state sequentially. At most one invocation of f is active at a time.
Asynchronously transforms elements while threading state sequentially. At most one invocation of f is active at a time.
Attributes
- Source
- Stream.scala
Asynchronously transforms each element.
Transforms the error channel with f, leaving elements unchanged.
Asynchronously transforms the typed error channel. It runs only when the source fails with a typed error; callback failure is a defect.
Asynchronously transforms the typed error channel. It runs only when the source fails with a typed error; callback failure is a defect.
Attributes
- Source
- Stream.scala
Applies f to each element using n concurrent workers. Output is UNORDERED (arrival order, not input order). On JVM, workers run on virtual threads. On JS, degrades to sequential map. n must be at least one; failure or cancellation stops the workers and closes upstream.
Applies f to each element using n concurrent workers. Output is UNORDERED (arrival order, not input order). On JVM, workers run on virtual threads. On JS, degrades to sequential map. n must be at least one; failure or cancellation stops the workers and closes upstream.
Value parameters
- f
-
transformation to apply to each element
- n
-
number of concurrent workers
Attributes
- Source
- Stream.scala
Applies an asynchronous callback with at most n callbacks in flight. Results are emitted in completion order. n must be at least one; callback failure is a defect, and failure or cancellation stops all active callbacks and closes upstream.
Applies an asynchronous callback with at most n callbacks in flight. Results are emitted in completion order. n must be at least one; callback failure is a defect, and failure or cancellation stops all active callbacks and closes upstream.
Attributes
- Source
- Stream.scala
Falls back to that on the first typed error; defects are not handled. Alias: ||.
Falls back to that on the first typed error; defects are not handled. Alias: ||.
Attributes
- Source
- Stream.scala
Rematerializes this stream after each clean completion, producing an infinite repetition when a cycle emits elements. Typed errors and defects terminate repetition; closing the result closes the active cycle.
Rematerializes this stream after each clean completion, producing an infinite repetition when a cycle emits elements. Typed errors and defects terminate repetition; closing the result closes the active cycle.
Attributes
- Source
- Stream.scala
Runs this stream through the asynchronous drain of sink. Materialization and cleanup are lazy, cancellation-safe, and performed exactly once.
Runs this stream through the asynchronous drain of sink. Materialization and cleanup are lazy, cancellation-safe, and performed exactly once.
Attributes
- Source
- Stream.scala
Runs the stream asynchronously and collects all elements in order. This requires memory proportional to the entire output and does not terminate for an infinite stream.
Runs the stream asynchronously and collects all elements in order. This requires memory proportional to the entire output and does not terminate for an infinite stream.
Attributes
- Source
- Stream.scala
Runs the stream asynchronously, discarding all elements.
Specialized asynchronous fold with a Double accumulator.
Specialized asynchronous fold with a Float accumulator.
Specialized asynchronous fold with an Int accumulator.
Specialized asynchronous fold with a Long accumulator.
Runs the stream, folding sequentially with an asynchronous callback.
Runs the stream, applying the asynchronous callback sequentially.
Emits the accumulator at each step, starting with init. The output stream has one more element than the input.
Emits the accumulator at each step, starting with init. The output stream has one more element than the input.
Attributes
- Source
- Stream.scala
Asynchronously emits the accumulator at each step, starting with init. The output stream has one more element than the input.
Asynchronously emits the accumulator at each step, starting with init. The output stream has one more element than the input.
Attributes
- Source
- Stream.scala
Emits sliding windows of up to n elements as Chunks, preserving order. Each window starts step elements after the previous one; gaps are skipped when step > n. One final partial window is emitted when it adds elements not present in the preceding window. Both arguments must be at least one.
Emits sliding windows of up to n elements as Chunks, preserving order. Each window starts step elements after the previous one; gaps are skipped when step > n. One final partial window is emitted when it adds elements not present in the preceding window. Both arguments must be at least one.
Attributes
- Source
- Stream.scala
Materializes this stream as a caller-owned asynchronous reader. The caller must drive and await close() on the published reader.
Materializes this stream as a caller-owned asynchronous reader. The caller must drive and await close() on the published reader.
Attributes
- Source
- Stream.scala
Emits at most the first n elements, then closes upstream. n <= 0 yields an empty stream without pulling an element.
Emits at most the first n elements, then closes upstream. n <= 0 yields an empty stream without pulling an element.
Attributes
- Source
- Stream.scala
Emits elements while pred holds, then closes on the first element where pred returns false.
Emits elements while pred holds, then closes on the first element where pred returns false.
Attributes
- Source
- Stream.scala
Tests elements sequentially and emits them while the asynchronous predicate holds, then closes upstream at the first false. Predicate failure is a defect.
Tests elements sequentially and emits them while the asynchronous predicate holds, then closes upstream at the first false. Predicate failure is a defect.
Attributes
- Source
- Stream.scala
Applies f to each element for side-effects, passing the element through.
Applies f to each element for side-effects, passing the element through.
Attributes
- Source
- Stream.scala
Runs an asynchronous effect for each element and passes it through.
Returns render.
Uses an asynchronous reader and awaits its close on every outcome.
Transforms this stream by applying a Pipeline.
Inherited methods
Returns the number of emitted elements, or the stream's typed error.
Returns the number of emitted elements, or the stream's typed error.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Tests whether any element satisfies pred, or returns the stream's typed error.
Tests whether any element satisfies pred, or returns the stream's typed error.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Returns the first element satisfying pred, or None if no element does.
Returns the first element satisfying pred, or None if no element does.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Tests whether every element satisfies pred, or returns the stream's typed error.
Tests whether every element satisfies pred, or returns the stream's typed error.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Alias for runForeach.
Alias for runForeach.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Returns the first element, or None if this stream is empty.
Returns the first element, or None if this stream is empty.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Returns the last element, or None if this stream is empty.
Returns the last element, or None if this stream is empty.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Runs this stream through sink, blocking until completion.
Runs this stream through sink, blocking until completion.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Collects all emitted elements into a Chunk, blocking until completion.
Collects all emitted elements into a Chunk, blocking until completion.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Consumes and discards all emitted elements, blocking until completion.
Consumes and discards all emitted elements, blocking until completion.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Folds emitted elements from z with f, blocking until completion.
Folds emitted elements from z with f, blocking until completion.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Folds emitted elements from z with f, blocking until completion.
Folds emitted elements from z with f, blocking until completion.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Folds emitted elements from z with f, blocking until completion.
Folds emitted elements from z with f, blocking until completion.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Folds emitted elements from z with f, blocking until completion.
Folds emitted elements from z with f, blocking until completion.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Applies f to every emitted element, blocking until completion.
Applies f to every emitted element, blocking until completion.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala
Materializes this stream as a scoped synchronous reader. Closing the scope closes the reader; asynchronous boundaries are bridged by the JVM runtime.
Materializes this stream as a scoped synchronous reader. Closing the scope closes the reader; asynchronous boundaries are bridged by the JVM runtime.
Attributes
- Inherited from:
- StreamPlatformSpecific
- Source
- StreamPlatformSpecific.scala