diff --git "a/.opencode/node_modules/effect/dist/Stream.d.ts" "b/.opencode/node_modules/effect/dist/Stream.d.ts" --- "a/.opencode/node_modules/effect/dist/Stream.d.ts" +++ "b/.opencode/node_modules/effect/dist/Stream.d.ts" @@ -1,4 +1,13 @@ /** + * Describes effectful sources that emit values over time. + * + * A `Stream` can emit many `A` values, fail with `E`, and require + * services `R` while it is being consumed. Streams are useful for data that is + * pulled in steps, such as values from collections, queues, pubsubs, schedules, + * callbacks, async iterables, or platform streams. The APIs here cover the full + * stream lifecycle: create a stream, transform or combine it, control buffering + * and timing, handle failures, and finally consume it. + * * @since 2.0.0 */ import * as Arr from "./Array.ts"; @@ -17,7 +26,7 @@ import type { Severity } from "./LogLevel.ts"; import * as Option from "./Option.ts"; import type { Pipeable } from "./Pipeable.ts"; import type { Predicate, Refinement } from "./Predicate.ts"; -import type * as PubSub from "./PubSub.ts"; +import * as PubSub from "./PubSub.ts"; import * as Pull from "./Pull.ts"; import * as Queue from "./Queue.ts"; import * as Result from "./Result.ts"; @@ -26,27 +35,42 @@ import * as Scope from "./Scope.ts"; import * as Sink from "./Sink.ts"; import type * as Take from "./Take.ts"; import type { ParentSpan, SpanOptions } from "./Tracer.ts"; -import type { Covariant, ExcludeReason, ExcludeTag, ExtractReason, ExtractTag, NarrowReason, NoInfer, OmitReason, ReasonTags, Tags, unassigned } from "./Types.ts"; +import type { Covariant, ExcludeReason, ExcludeTag, ExtractReason, ExtractTag, NarrowReason, NoInfer, OmitReason, ReasonTags, Tags, TupleOf, unassigned } from "./Types.ts"; import type * as Unify from "./Unify.ts"; /** + * String literal type used as the unique brand for `Stream` values. + * + * @category type IDs * @since 4.0.0 - * @category Type Identifiers */ export type TypeId = "~effect/Stream"; /** + * Runtime identifier stored on `Stream` values and used by `isStream` to + * recognize them. + * + * **Details** + * + * This marker is part of the runtime representation of `Stream` values. Prefer + * `isStream` when narrowing unknown values. + * + * @see {@link isStream} for the public guard that checks this identifier + * + * @category type IDs * @since 4.0.0 - * @category Type Identifiers */ export declare const TypeId: TypeId; /** * A `Stream` describes a program that can emit many `A` values, fail * with `E`, and require `R`. * + * **Details** + * * Streams are pull-based with backpressure and emit chunks to amortize effect * evaluation. They support monadic composition and error handling similar to * `Effect`, adapted for multiple values. * - * @example + * **Example** (Creating and consuming streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -64,8 +88,8 @@ export declare const TypeId: TypeId; * // 6 * ``` * + * @category models * @since 2.0.0 - * @category Models */ export interface Stream extends Variance, Pipeable { readonly channel: Channel.Channel, E, void, unknown, unknown, unknown, R>; @@ -76,20 +100,8 @@ export interface Stream extends Variance - * declare const effect: Effect.Effect - * - * // The unification system handles mixed operations - * const combined = Effect.zip(stream.pipe(Stream.runCollect), effect) - * ``` - * + * @category models * @since 2.0.0 - * @category Models */ export interface StreamUnify + * type NumberStream = HKT.Kind * // Equivalent to: Stream * ``` * - * @category Type Lambdas + * @category type lambdas * @since 2.0.0 */ export interface StreamTypeLambda extends TypeLambda { readonly type: Stream; } /** - * Variance markers for Stream type parameters. + * Type-level variance marker for `Stream`. * + * **Details** + * + * The emitted value `A`, error `E`, and service requirement `R` type + * parameters are covariant. + * + * @category models * @since 2.0.0 - * @category Models */ export interface Variance { readonly [TypeId]: VarianceStruct; } /** - * Structural encoding of Stream type parameter variance. + * Structural encoding used by `Variance` to record each `Stream` type + * parameter's variance. * - * @since 2.0.0 - * @category Models + * **Details** + * + * `_A`, `_E`, and `_R` are covariant markers. + * + * @category models + * @since 3.4.0 */ export interface VarianceStruct { readonly _A: Covariant; @@ -156,7 +169,8 @@ export interface VarianceStruct { /** * Extract the success type from a Stream type. * - * @example + * **Example** (Extracting the success type from a Stream type) + * * ```ts * import type { Stream } from "effect" * @@ -165,14 +179,15 @@ export interface VarianceStruct { * // SuccessType is number * ``` * + * @category utility types * @since 3.4.0 - * @category Type-Level */ export type Success> = [T] extends [Stream] ? _A : never; /** * Extract the error type from a Stream type. * - * @example + * **Example** (Extracting the error type from a Stream type) + * * ```ts * import type { Stream } from "effect" * @@ -181,18 +196,15 @@ export type Success> = [T] extends [Stream> = [T] extends [Stream] ? _E : never; /** * Extract the services type from a Stream type. * - * **Previously Known As:** + * **Example** (Extracting the services type from a Stream type) * - * This type alias was named `Context` in Effect 3.x. - * - * @example * ```ts * import type { Stream } from "effect" * @@ -204,14 +216,15 @@ export type Error> = [T] extends [Stream> = [T] extends [Stream] ? _R : never; /** * Checks whether a value is a Stream. * - * @example + * **Example** (Checking whether a value is a Stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -228,14 +241,15 @@ export type Services> = [T] extends [Stream u is Stream; /** * The default chunk size used by Stream constructors and combinators. * - * @example + * **Example** (Reading the default chunk size) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -247,27 +261,22 @@ export declare const isStream: (u: unknown) => u is Stream, E, R>(channel: Channel.Channel) => Stream ? A : never, E, R>; /** - * Either emits the success value of this effect or terminates the stream - * with the failure value of this effect. + * Creates a stream from an effect. + * + * **Example** (Creating a stream from an effect) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -303,16 +312,17 @@ export declare const fromChannel: , E * // Output: [ 42 ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const fromEffect: (effect: Effect.Effect) => Stream; /** * Accesses a service from the context and emits it as a single element. * - * @example + * **Example** (Accessing a service as a stream) + * * ```ts - * import { Effect, Context, Stream } from "effect" + * import { Context, Effect, Stream } from "effect" * * class Greeter extends Context.Service string @@ -335,17 +345,23 @@ export declare const fromEffect: (effect: Effect.Effect) => St * // Output: [ "Hello, World!" ] * ``` * + * @category context * @since 4.0.0 - * @category Context */ export declare const service: (service: Context.Key) => Stream; /** * Optionally accesses a service from the context and emits the result as a * single element. * - * @example + * **When to use** + * + * Use when you need a stream that emits an optional service from the context + * without requiring that service to be present. + * + * **Example** (Accessing an optional service as a stream) + * * ```ts - * import { Effect, Option, Context, Stream } from "effect" + * import { Context, Effect, Option, Stream } from "effect" * * class Greeter extends Context.Service string @@ -373,14 +389,15 @@ export declare const service: (service: Context.Key) => Stream(service: Context.Key) => Stream>; /** * Creates a stream that runs the effect and emits no elements. * - * @example + * **Example** (Draining an effect into a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -394,20 +411,15 @@ export declare const serviceOption: (service: Context.Key) => Stream * // Output: Draining side effect * ``` * + * @category constructors * @since 4.0.0 - * @category Constructors */ export declare const fromEffectDrain: (effect: Effect.Effect) => Stream; /** * Creates a stream from an effect producing a value of type `A` which repeats forever. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Repeating an effect forever) * - * - `Stream.repeatEffect` - * - * @example * ```ts * import { Console, Effect, Random, Stream } from "effect" * @@ -423,21 +435,16 @@ export declare const fromEffectDrain: (effect: Effect.Effect) * // Output: [ 3891571149, 4239494205, 2352981603, 2339111046, 1488052210 ] * ``` * + * @category constructors * @since 4.0.0 - * @category Constructors */ export declare const fromEffectRepeat: (effect: Effect.Effect) => Stream, R>; /** * Creates a stream from an effect producing a value of type `A`, which is * repeated using the specified schedule. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Repeating an effect with a schedule) * - * - `Stream.repeatEffectWithSchedule` - * - * @example * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -454,14 +461,16 @@ export declare const fromEffectRepeat: (effect: Effect.Effect) * // Output: [ "ping", "ping", "ping" ] * ``` * - * @since 2.0.0 - * @category Constructors + * @category constructors + * @since 4.0.0 */ export declare const fromEffectSchedule: (effect: Effect.Effect, schedule: Schedule.Schedule) => Stream; /** - * Creates a stream that emits void values spaced by the specified duration. + * Creates a stream that emits `void` immediately once, then emits another + * `void` after each specified interval. + * + * **Example** (Emitting ticks on an interval) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -477,17 +486,20 @@ export declare const fromEffectSchedule: (effe * // Output: [ undefined, undefined, undefined ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const tick: (interval: Duration.Input) => Stream; /** * Creates a stream from a pull effect, such as one produced by `Stream.toPull`. * + * **Details** + * * A pull effect yields chunks on demand and completes when the upstream stream ends. * See `Stream.toPull` for a matching producer. * - * @example + * **Example** (Creating a stream from a pull effect) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -505,14 +517,15 @@ export declare const tick: (interval: Duration.Input) => Stream; * // Output: [1, 2, 3] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const fromPull: (pull: Effect.Effect, E, void, R>, EX, RX>) => Stream | EX, R | RX>; /** - * Derive a stream by transforming its pull effect. + * Derives a stream by transforming its pull effect. + * + * **Example** (Transforming a pull effect) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -529,17 +542,20 @@ export declare const fromPull: (pull: Effect.Effect(self: Stream, f: (pull: Pull.Pull, E, void>, scope: Scope.Scope) => Effect.Effect, E2, void, R2>, EX, RX>) => Stream, R | R2 | RX>; /** * Transforms a stream by effectfully transforming its pull effect. * + * **Details** + * * A forked scope is also provided to the transformation function, which is * closed once the resulting stream has finished processing. * - * @example + * **Example** (Transforming a stream by effectfully transforming its pull effect) + * * ```ts * import { Console, Effect, Scope, Stream } from "effect" * @@ -564,14 +580,15 @@ export declare const transformPull: (self: Stream(self: Stream, f: (pull: Pull.Pull, E, void, R>, scope: Scope.Scope, forkedScope: Scope.Scope) => Effect.Effect, E2, void, R2>, EX, RX>) => Stream, R | R2 | RX>; /** * Creates a channel from a stream. * - * @example + * **Example** (Converting a stream to a channel) + * * ```ts * import { Channel, Console, Effect, Stream } from "effect" * @@ -586,30 +603,24 @@ export declare const transformPullBracket: (self: St * // Output: [ 1, 2, 3 ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const toChannel: (stream: Stream) => Channel.Channel, E, void, unknown, unknown, unknown, R>; /** * Creates a stream from a callback that can emit values into a queue. * - * You can use the `Queue` with the apis from the `Queue` module to emit - * values to the stream or to signal the stream ending. + * **When to use** + * + * Use when you need callback-based code to emit stream values by offering to a + * `Queue`, or signal stream completion through the `Queue` module APIs. * * By default it uses an "unbounded" buffer size. * You can customize the buffer size and strategy by passing an object as the * second argument with the `bufferSize` and `strategy` fields. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Creating a stream from a callback that can emit values into a queue) * - * - `Stream.async` - * - `Stream.asyncEffect` - * - `Stream.asyncPush` - * - `Stream.asyncScoped` - * - * @example * ```ts * import { Console, Effect, Queue, Stream } from "effect" * @@ -633,8 +644,8 @@ export declare const toChannel: (stream: Stream) => Channel.Ch * Effect.runPromise(program) * ``` * - * @since 2.0.0 - * @category Constructors + * @category constructors + * @since 4.0.0 */ export declare const callback: (f: (queue: Queue.Queue) => Effect.Effect, options?: { readonly bufferSize?: number | undefined; @@ -643,7 +654,8 @@ export declare const callback: (f: (queue: Queue.Queue< /** * Creates an empty stream. * - * @example + * **Example** (Creating an empty stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -656,14 +668,15 @@ export declare const callback: (f: (queue: Queue.Queue< * // [] * ``` * - * @since 4.0.0 - * @category Constructors + * @category constructors + * @since 2.0.0 */ export declare const empty: Stream; /** * Creates a single-valued pure stream. * - * @example + * **Example** (Creating a single-valued pure stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -676,14 +689,15 @@ export declare const empty: Stream; * // [ 3 ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const succeed: (value: A) => Stream; /** * Creates a stream from a sequence of values. * - * @example + * **Example** (Creating a stream from a sequence of values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -697,16 +711,19 @@ export declare const succeed: (value: A) => Stream; * Effect.runPromise(program) * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const make: >(...values: As) => Stream; /** * Creates a stream that synchronously evaluates a function and emits the result as a single value. * + * **Details** + * * The function is evaluated each time the stream is run. * - * @example + * **Example** (Evaluating a value synchronously) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -719,16 +736,19 @@ export declare const make: >(...values: As) * // Output: [ 3 ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const sync: (evaluate: LazyArg) => Stream; /** * Creates a lazily constructed stream. * + * **Details** + * * The stream factory is evaluated each time the stream is run. * - * @example + * **Example** (Creating a lazily constructed stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -741,14 +761,15 @@ export declare const sync: (evaluate: LazyArg) => Stream; * // Output: [ 1, 2, 3 ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const suspend: (stream: LazyArg>) => Stream; /** * Terminates with the specified error. * - * @example + * **Example** (Failing a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -762,14 +783,15 @@ export declare const suspend: (stream: LazyArg>) => Str * Effect.runPromise(program) * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const fail: (error: E) => Stream; /** * Terminates with the specified lazily evaluated error. * - * @example + * **Example** (Failing a stream lazily) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -785,14 +807,15 @@ export declare const fail: (error: E) => Stream; * // { _id: 'Exit', _tag: 'Failure', cause: { _id: 'Cause', _tag: 'Fail', failure: 'Uh oh!' } } * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const failSync: (evaluate: LazyArg) => Stream; /** * Creates a stream that fails with the specified `Cause`. * - * @example + * **Example** (Failing with a cause) + * * ```ts * import { Cause, Console, Effect, Stream } from "effect" * @@ -809,14 +832,15 @@ export declare const failSync: (evaluate: LazyArg) => Stream; * Effect.runPromise(program) * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const failCause: (cause: Cause.Cause) => Stream; /** * The stream that dies with the specified defect. * - * @example + * **Example** (Dying with a defect) + * * ```ts * import { Cause, Console, Effect, Exit, Stream } from "effect" * @@ -840,14 +864,15 @@ export declare const failCause: (cause: Cause.Cause) => Stream; * // Output: Exit.Failure(Error: Boom) * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const die: (defect: unknown) => Stream; /** * The stream that always fails with the specified lazily evaluated `Cause`. * - * @example + * **Example** (Failing with a lazy cause) + * * ```ts * import { Cause, Console, Effect, Stream } from "effect" * @@ -865,16 +890,19 @@ export declare const die: (defect: unknown) => Stream; * // { _id: 'Exit', _tag: 'Failure', cause: { _id: 'Cause', _tag: 'Fail', failure: 'Connection timeout after retries' } } * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const failCauseSync: (evaluate: LazyArg>) => Stream; /** * Creates a stream that consumes values from an iterator. * + * **Details** + * * The `maxChunkSize` parameter controls how many values are pulled per chunk. * - * @example + * **Example** (Consuming values from an iterator) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -895,18 +923,19 @@ export declare const failCauseSync: (evaluate: LazyArg>) => St * // Output: [ 1, 2, 3 ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const fromIteratorSucceed: (iterator: IterableIterator, maxChunkSize?: number) => Stream; /** * Creates a new `Stream` from an iterable collection of values. * - * **Options** + * **Details** * * - `chunkSize`: Maximum number of values emitted per chunk. * - * @example + * **Example** (Creating a stream from an iterable) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -922,8 +951,8 @@ export declare const fromIteratorSucceed: (iterator: IterableIterator, max * // Output: [ 1, 2, 3 ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const fromIterable: (iterable: Iterable, options?: { readonly chunkSize?: number | undefined; @@ -931,9 +960,15 @@ export declare const fromIterable: (iterable: Iterable, options?: { /** * Creates a stream from an effect producing an iterable of values. * - * @example + * **When to use** + * + * Use when the iterable must be acquired from an Effect before the stream emits, + * and acquisition services or failures should be part of the stream. + * + * **Example** (Creating a stream from an iterable effect) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class UserRepo extends Context.Service> @@ -959,20 +994,15 @@ export declare const fromIterable: (iterable: Iterable, options?: { * // Output: [ "user1", "user2" ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const fromIterableEffect: (iterable: Effect.Effect, E, R>) => Stream; /** * Creates a stream by repeatedly running an effect that yields an iterable of values. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Repeating an iterable effect) * - * - `Stream.repeatEffectChunk` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -988,20 +1018,15 @@ export declare const fromIterableEffect: (iterable: Effect.Effect(iterable: Effect.Effect, E, R>) => Stream, R>; /** * Creates a stream from an array of values. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Creating a stream from an array of values) * - * - `Stream.fromChunk` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1015,14 +1040,20 @@ export declare const fromIterableEffectRepeat: (iterable: Effect.Effect * // Output: [ 1, 2, 3 ] * ``` * + * @category constructors * @since 4.0.0 - * @category Constructors */ export declare const fromArray: (array: ReadonlyArray) => Stream; /** * Creates a stream from an effect that produces an array of values. * - * @example + * **When to use** + * + * Use when the array must be acquired from an Effect before the stream emits, + * and acquisition services or failures should be part of the stream. + * + * **Example** (Creating a stream from an effect that produces an array of values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1036,20 +1067,15 @@ export declare const fromArray: (array: ReadonlyArray) => Stream; * // Output: [ "Ada", "Grace" ] * ``` * + * @category constructors * @since 4.0.0 - * @category Constructors */ export declare const fromArrayEffect: (effect: Effect.Effect, E, R>) => Stream, R>; /** * Creates a stream from an arbitrary number of arrays. * - * **Previously Known As** + * **Example** (Creating a stream from an arbitrary number of arrays) * - * This API replaces the following from Effect 3.x: - * - * - `Stream.fromChunks` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1063,19 +1089,20 @@ export declare const fromArrayEffect: (effect: Effect.Effect>>(...arrays: Arr) => Stream; /** - * Creates a stream from a queue of values. + * Creates a stream that pulls values from a `Queue.Dequeue`. * - * **Options** + * **Details** * - * - `maxChunkSize`: The maximum number of queued elements to put in one chunk in the stream - * - `shutdown`: If `true`, the queue will be shutdown after the stream is evaluated (defaults to `false`) + * The stream emits non-empty batches of queued values and ends when the queue + * fails with `Cause.Done`; other queue failures are propagated. + * + * **Example** (Creating a stream from a queue of values) * - * @example * ```ts * import { Console, Effect, Queue, Stream } from "effect" * @@ -1095,14 +1122,15 @@ export declare const fromArrays: >> * // Output: [ 1, 2, 3 ] * ``` * - * @since 4.0.0 - * @category Constructors + * @category constructors + * @since 2.0.0 */ export declare const fromQueue: (queue: Queue.Dequeue) => Stream>; /** * Creates a stream from a subscription to a `PubSub`. * - * @example + * **Example** (Creating a stream from a subscription to a PubSub) + * * ```ts * import { Console, Effect, Fiber, PubSub, Stream } from "effect" * @@ -1127,16 +1155,19 @@ export declare const fromQueue: (queue: Queue.Dequeue) => Stream(pubsub: PubSub.PubSub) => Stream; /** * Creates a stream from a PubSub of `Take` values. * + * **Details** + * * `Take` values include end and failure signals. * - * @example + * **Example** (Creating a stream from PubSub takes) + * * ```ts * import { Console, Effect, Exit, PubSub, Stream, Take } from "effect" * @@ -1157,16 +1188,21 @@ export declare const fromPubSub: (pubsub: PubSub.PubSub) => Stream; * // Output: [ 1, 2 ] * ``` * + * @category constructors * @since 4.0.0 - * @category Constructors */ export declare const fromPubSubTake: (pubsub: PubSub.PubSub>) => Stream; /** - * Creates a stream from a `ReadableStream`. + * Creates a stream from a lazily supplied Web `ReadableStream`. * - * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream. + * **Details** + * + * The stream reads from a `ReadableStreamDefaultReader`, maps read failures + * with `onError`, and closes the reader when the stream finalizes. By default + * the reader is canceled; set `releaseLockOnEnd` to release the lock instead. + * + * **Example** (Creating a stream from a ReadableStream) * - * @example * ```ts * import { Console, Data, Effect, Stream } from "effect" * @@ -1194,8 +1230,8 @@ export declare const fromPubSubTake: (pubsub: PubSub.PubSub(options: { readonly evaluate: LazyArg>; @@ -1205,9 +1241,10 @@ export declare const fromReadableStream: (options: { /** * Creates a stream from an AsyncIterable. * - * @example + * **Example** (Creating a stream from an AsyncIterable) + * * ```ts - * import { Console, Data, Effect, Stream } from "effect" + * import { Data, Effect, Stream } from "effect" * * class StreamError extends Data.TaggedError("StreamError")<{ readonly cause: unknown }> {} * @@ -1217,25 +1254,25 @@ export declare const fromReadableStream: (options: { * yield 3 * })() * - * const program = Effect.gen(function*() { + * Effect.runPromise(Effect.gen(function*() { * const stream = Stream.fromAsyncIterable(iterable, (cause) => new StreamError({ cause })) * const values = yield* Stream.runCollect(stream) - * yield* Console.log(values) - * }) + * yield* Effect.sync(() => console.log(values)) + * })) * - * Effect.runPromise(program) - * // Output: [ 1, 2, 3 ] + * // [ 1, 2, 3 ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const fromAsyncIterable: (iterable: AsyncIterable, onError: (error: unknown) => E) => Stream; /** * Creates a stream that emits each output of a schedule that does not require input, * for as long as the schedule continues. * - * @example + * **Example** (Creating a stream from a schedule) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -1252,17 +1289,21 @@ export declare const fromAsyncIterable: (iterable: AsyncIterable, onErr * // Output: [ 0, 1, 2 ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const fromSchedule: (schedule: Schedule.Schedule) => Stream; /** * Creates a stream from a PubSub subscription. * - * Use `PubSub.subscribe` to create the subscription and `Stream.take` or - * cancellation to control how many values are consumed. + * **When to use** + * + * Use when you already have a `PubSub.Subscription` and want to expose its + * messages as a `Stream`, with `Stream.take` or cancellation controlling how + * many values are consumed. + * + * **Example** (Creating a stream from a PubSub subscription) * - * @example * ```ts * import { Console, Effect, PubSub, Stream } from "effect" * @@ -1282,15 +1323,15 @@ export declare const fromSchedule: (schedule: Schedule.Schedule(pubsub: PubSub.Subscription) => Stream; /** * Interface representing an event listener target. * + * @category models * @since 3.4.0 - * @category Models */ export interface EventListener { addEventListener(event: string, f: (event: A) => void, options?: { @@ -1306,26 +1347,35 @@ export interface EventListener { /** * Creates a stream from an event listener. * - * @example + * **Example** (Creating a stream from an event listener) + * * ```ts - * import { Console, Effect, Stream } from "effect" + * import { Effect, Stream } from "effect" * - * declare const target: Stream.EventListener + * class NumberTarget implements Stream.EventListener { + * addEventListener(event: string, f: (event: number) => void) { + * if (event === "data") { + * f(1) + * f(2) + * f(3) + * } + * } + * removeEventListener(_event: string, _f: (event: number) => void) {} + * } * - * const program = Effect.gen(function*() { - * const stream = Stream.fromEventListener(target, "data").pipe( + * Effect.runPromise(Effect.gen(function*() { + * const stream = Stream.fromEventListener(new NumberTarget(), "data").pipe( * Stream.take(3) * ) * const values = yield* Stream.runCollect(stream) - * yield* Console.log(values) - * }) + * yield* Effect.sync(() => console.log(values)) + * })) * - * Effect.runPromise(program) - * // Output: [ 1, 2, 3 ] + * // [ 1, 2, 3 ] * ``` * + * @category constructors * @since 3.1.0 - * @category Constructors */ export declare const fromEventListener: (target: EventListener, type: string, options?: boolean | { readonly capture?: boolean; @@ -1334,9 +1384,16 @@ export declare const fromEventListener: (target: EventListener, readonly bufferSize?: number | undefined; } | undefined) => Stream; /** - * Creates a stream by peeling off successive layers of a state value. + * Creates a stream by repeatedly applying an effectful step function to a + * state. + * + * **Details** + * + * Each `readonly [value, nextState]` result emits `value` and continues with + * `nextState`; returning `undefined` ends the stream. + * + * **Example** (Unfolding stream state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1350,19 +1407,27 @@ export declare const fromEventListener: (target: EventListener, * // Output: [ 1, 2, 3, 4, 5 ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const unfold: (s: S, f: (s: S) => Effect.Effect) => Stream; /** - * Like `Stream.unfold`, but allows the emission of values to end one step further - * than the unfolding of the state. This is useful for embedding paginated APIs, - * hence the name. + * Creates a stream by repeatedly evaluating an effectful page function. + * + * **When to use** + * + * Use to consume paginated APIs where each step returns a batch of values + * together with an optional next state. + * + * **Details** + * + * This is similar to {@link unfold}, but each step can emit zero or more values + * and independently decide whether another state should be requested. + * + * **Example** (Paginating stream state) * - * @example * ```ts - * import { Console, Effect, Stream } from "effect" - * import * as Option from "effect/Option" + * import { Console, Effect, Option, Stream } from "effect" * * const stream = Stream.paginate(0, (n: number) => * Effect.succeed( @@ -1376,14 +1441,15 @@ export declare const unfold: (s: S, f: (s: S) => Effect.Effect(s: S, f: (s: S) => Effect.Effect, Option.Option], E, R>) => Stream; /** * Creates an infinite stream by repeatedly applying a function to a seed value. * - * @example + * **Example** (Iterating from a seed value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1398,17 +1464,20 @@ export declare const paginate: (s: S, f: (s: S) => E * // Output: [ 1, 2, 3 ] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const iterate: (value: A, next: (value: A) => A) => Stream; /** * Constructs a stream from a range of integers, including both endpoints. * + * **Details** + * * If the provided `min` is greater than `max`, the stream will not emit any * values. * - * @example + * **Example** (Creating a numeric range) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1420,14 +1489,16 @@ export declare const iterate: (value: A, next: (value: A) => A) => Stream; * Effect.runPromise(program) * // Output: [ 1, 2, 3, 4, 5 ] * ``` - * @since 4.0.0 - * @category Constructors + * + * @category constructors + * @since 2.0.0 */ export declare const range: (min: number, max: number, chunkSize?: number) => Stream; /** * The stream that never produces any value or fails with any error. * - * @example + * **Example** (Creating a never-ending stream) + * * ```ts * import { Effect, Stream } from "effect" * @@ -1440,14 +1511,15 @@ export declare const range: (min: number, max: number, chunkSize?: number) => St * // [] * ``` * - * @since 4.0.0 - * @category Constructors + * @category constructors + * @since 2.0.0 */ export declare const never: Stream; /** * Creates a stream produced from an `Effect`. * - * @example + * **Example** (Unwrapping a stream effect) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1462,15 +1534,16 @@ export declare const never: Stream; * // [1, 2, 3] * ``` * + * @category constructors * @since 2.0.0 - * @category Constructors */ export declare const unwrap: (effect: Effect.Effect, E, R>) => Stream>; /** * Runs a stream that requires `Scope` in a managed scope, ensuring its * finalizers are run when the stream completes. * - * @example + * **Example** (Scoping a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1489,14 +1562,15 @@ export declare const unwrap: (effect: Effect.Effect(self: Stream) => Stream>; /** * Transforms the elements of this stream using the supplied function. * - * @example + * **Example** (Mapping stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1509,14 +1583,15 @@ export declare const scoped: (self: Stream) => Stream(f: (a: A, i: number) => B): (self: Stream) => Stream; /** * Transforms the elements of this stream using the supplied function. * - * @example + * **Example** (Mapping stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1549,15 +1625,16 @@ export declare const map: { * // [ 1, 3, 5 ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ (self: Stream, f: (a: A, i: number) => B): Stream; }; /** * Maps both the failure and success channels of a stream. * - * @example + * **Example** (Mapping both the failure and success channels of a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1586,14 +1663,15 @@ export declare const map: { * // Output: [ "error: boom" ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ export declare const mapBoth: { /** * Maps both the failure and success channels of a stream. * - * @example + * **Example** (Mapping both the failure and success channels of a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1622,8 +1700,8 @@ export declare const mapBoth: { * // Output: [ "error: boom" ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ (options: { readonly onFailure: (e: E) => E2; @@ -1632,7 +1710,8 @@ export declare const mapBoth: { /** * Maps both the failure and success channels of a stream. * - * @example + * **Example** (Mapping both the failure and success channels of a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1661,8 +1740,8 @@ export declare const mapBoth: { * // Output: [ "error: boom" ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ (self: Stream, options: { readonly onFailure: (e: E) => E2; @@ -1672,13 +1751,8 @@ export declare const mapBoth: { /** * Transforms each emitted chunk using the provided function, which receives the chunk and its index. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Mapping stream chunks) * - * - `Stream.mapChunks` - * - * @example * ```ts * import { Array, Console, Effect, Stream } from "effect" * @@ -1695,20 +1769,15 @@ export declare const mapBoth: { * // Output: [ 1, 2, 4, 5 ] * ``` * - * @since 2.0.0 - * @category Mapping + * @category mapping + * @since 4.0.0 */ export declare const mapArray: { /** * Transforms each emitted chunk using the provided function, which receives the chunk and its index. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Mapping stream chunks) * - * - `Stream.mapChunks` - * - * @example * ```ts * import { Array, Console, Effect, Stream } from "effect" * @@ -1725,20 +1794,15 @@ export declare const mapArray: { * // Output: [ 1, 2, 4, 5 ] * ``` * - * @since 2.0.0 - * @category Mapping + * @category mapping + * @since 4.0.0 */ (f: (a: Arr.NonEmptyReadonlyArray, i: number) => Arr.NonEmptyReadonlyArray): (self: Stream) => Stream; /** * Transforms each emitted chunk using the provided function, which receives the chunk and its index. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Mapping stream chunks) * - * - `Stream.mapChunks` - * - * @example * ```ts * import { Array, Console, Effect, Stream } from "effect" * @@ -1755,15 +1819,21 @@ export declare const mapArray: { * // Output: [ 1, 2, 4, 5 ] * ``` * - * @since 2.0.0 - * @category Mapping + * @category mapping + * @since 4.0.0 */ (self: Stream, f: (a: Arr.NonEmptyReadonlyArray, i: number) => Arr.NonEmptyReadonlyArray): Stream; }; /** * Maps over elements of the stream with the specified effectful function. * - * @example + * **When to use** + * + * Use when each stream element transformation needs an Effect, service + * dependency, failure channel, or configured concurrency. + * + * **Example** (Effectfully mapping stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1791,14 +1861,20 @@ export declare const mapArray: { * // [2, 4, 6] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ export declare const mapEffect: { /** * Maps over elements of the stream with the specified effectful function. * - * @example + * **When to use** + * + * Use when each stream element transformation needs an Effect, service + * dependency, failure channel, or configured concurrency. + * + * **Example** (Effectfully mapping stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1826,8 +1902,8 @@ export declare const mapEffect: { * // [2, 4, 6] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ (f: (a: A, i: number) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded" | undefined; @@ -1836,7 +1912,13 @@ export declare const mapEffect: { /** * Maps over elements of the stream with the specified effectful function. * - * @example + * **When to use** + * + * Use when each stream element transformation needs an Effect, service + * dependency, failure channel, or configured concurrency. + * + * **Example** (Effectfully mapping stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1864,8 +1946,8 @@ export declare const mapEffect: { * // [2, 4, 6] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ (self: Stream, f: (a: A, i: number) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded" | undefined; @@ -1875,7 +1957,13 @@ export declare const mapEffect: { /** * Flattens a stream of `Effect` values into a stream of their results. * - * @example + * **When to use** + * + * Use when stream elements already are effects and their successes should become + * stream elements while their failures enter the stream error channel. + * + * **Example** (Flattening a stream of Effect values into a stream of their results) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -1890,8 +1978,8 @@ export declare const mapEffect: { * // Output: [1, 2, 3] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ export declare const flattenEffect: , any, any> | { readonly concurrency?: number | "unbounded" | undefined; @@ -1904,15 +1992,15 @@ export declare const flattenEffect: [Arg] extends [Stream, infer _E, infer _R>] ? Stream<_A, _EX | _E, _RX | _R> : (self: Stream, E, R>) => Stream; /** - * Effectfully maps over non-empty array chunks emitted by the stream. + * Maps over non-empty array chunks emitted by the stream effectfully. * - * **Previously Known As** + * **When to use** * - * This API replaces the following from Effect 3.x: + * Use when transformation needs to see and replace each non-empty emitted chunk + * effectfully instead of mapping individual stream elements. * - * - `Stream.mapChunksEffect` + * **Example** (Effectfully mapping stream chunks) * - * @example * ```ts * import { Array, Console, Effect, Stream } from "effect" * @@ -1931,20 +2019,20 @@ export declare const flattenEffect: (f: (a: Arr.NonEmptyReadonlyArray, i: number) => Effect.Effect, E2, R2>): (self: Stream) => Stream; /** - * Effectfully maps over non-empty array chunks emitted by the stream. + * Maps over non-empty array chunks emitted by the stream effectfully. * - * **Previously Known As** + * **When to use** * - * This API replaces the following from Effect 3.x: + * Use when transformation needs to see and replace each non-empty emitted chunk + * effectfully instead of mapping individual stream elements. * - * - `Stream.mapChunksEffect` + * **Example** (Effectfully mapping stream chunks) * - * @example * ```ts * import { Array, Console, Effect, Stream } from "effect" * @@ -1995,23 +2083,20 @@ export declare const mapArrayEffect: { * // Output: [1, 2, 13, 14] * ``` * + * @category mapping * @since 4.0.0 - * @category Mapping */ (self: Stream, f: (a: Arr.NonEmptyReadonlyArray, i: number) => Effect.Effect, E2, R2>): Stream; }; /** * Lifts failures and successes into a `Result`, yielding a stream that cannot fail. * - * The stream ends after the first failure, emitting a `Result.fail` value. - * - * **Previously Known As:** + * **Details** * - * This API replaces the following from Effect 3.x: + * The stream ends after the first failure, emitting a `Result.fail` value. * - * - `Stream.either` + * **Example** (Converting failures to results) * - * @example * ```ts * import { Console, Effect, Result, Stream } from "effect" * @@ -2032,14 +2117,15 @@ export declare const mapArrayEffect: { * // Output: [ "success: 1", "success: 2", "failure: boom" ] * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ export declare const result: (self: Stream) => Stream, never, R>; /** * Runs the provided effect for each element while preserving the elements. * - * @example + * **Example** (Tapping stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2065,14 +2151,15 @@ export declare const result: (self: Stream) => Stream(f: (a: NoInfer) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded" | undefined; @@ -2107,7 +2194,8 @@ export declare const tap: { /** * Runs the provided effect for each element while preserving the elements. * - * @example + * **Example** (Tapping stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2133,8 +2221,8 @@ export declare const tap: { * // [ 2, 4, 6 ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (self: Stream, f: (a: NoInfer) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded" | undefined; @@ -2143,7 +2231,8 @@ export declare const tap: { /** * Returns a stream that effectfully "peeks" at elements and failures. * - * @example + * **Example** (Tapping values and errors) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2168,14 +2257,15 @@ export declare const tap: { * // [ 1, 2, 3 ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ export declare const tapBoth: { /** * Returns a stream that effectfully "peeks" at elements and failures. * - * @example + * **Example** (Tapping values and errors) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2200,8 +2290,8 @@ export declare const tapBoth: { * // [ 1, 2, 3 ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (options: { readonly onElement: (a: NoInfer) => Effect.Effect; @@ -2211,7 +2301,8 @@ export declare const tapBoth: { /** * Returns a stream that effectfully "peeks" at elements and failures. * - * @example + * **Example** (Tapping values and errors) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2236,8 +2327,8 @@ export declare const tapBoth: { * // [ 1, 2, 3 ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (self: Stream, options: { readonly onElement: (a: NoInfer) => Effect.Effect; @@ -2246,10 +2337,10 @@ export declare const tapBoth: { }): Stream; }; /** - * Sends all elements emitted by this stream to the specified sink in addition - * to emitting them. + * Runs a sink for all stream elements while still emitting them downstream. + * + * **Example** (Tapping values with a sink) * - * @example * ```ts * import { Console, Effect, Ref, Sink, Stream } from "effect" * @@ -2272,15 +2363,15 @@ export declare const tapBoth: { * // Output: [1, 2, 3] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ export declare const tapSink: { /** - * Sends all elements emitted by this stream to the specified sink in addition - * to emitting them. + * Runs a sink for all stream elements while still emitting them downstream. + * + * **Example** (Tapping values with a sink) * - * @example * ```ts * import { Console, Effect, Ref, Sink, Stream } from "effect" * @@ -2303,15 +2394,15 @@ export declare const tapSink: { * // Output: [1, 2, 3] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (sink: Sink.Sink): (self: Stream) => Stream; /** - * Sends all elements emitted by this stream to the specified sink in addition - * to emitting them. + * Runs a sink for all stream elements while still emitting them downstream. + * + * **Example** (Tapping values with a sink) * - * @example * ```ts * import { Console, Effect, Ref, Sink, Stream } from "effect" * @@ -2334,15 +2425,23 @@ export declare const tapSink: { * // Output: [1, 2, 3] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (self: Stream, sink: Sink.Sink): Stream; }; /** - * Maps each element to a stream and concatenates the results in order. + * Maps each element to a stream and flattens the resulting streams. + * + * **Details** + * + * With the default sequential concurrency, inner streams are concatenated in + * input order. When `concurrency` is greater than `1` or `"unbounded"`, + * multiple inner streams may run at the same time and their outputs are merged + * as they arrive. + * + * **Example** (FlatMapping stream values) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2358,14 +2457,22 @@ export declare const tapSink: { * // Output: [ 1, 2, 2, 4, 3, 6 ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ export declare const flatMap: { /** - * Maps each element to a stream and concatenates the results in order. + * Maps each element to a stream and flattens the resulting streams. + * + * **Details** + * + * With the default sequential concurrency, inner streams are concatenated in + * input order. When `concurrency` is greater than `1` or `"unbounded"`, + * multiple inner streams may run at the same time and their outputs are merged + * as they arrive. + * + * **Example** (FlatMapping stream values) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2381,17 +2488,25 @@ export declare const flatMap: { * // Output: [ 1, 2, 2, 4, 3, 6 ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ (f: (a: A) => Stream, options?: { readonly concurrency?: number | "unbounded" | undefined; readonly bufferSize?: number | undefined; } | undefined): (self: Stream) => Stream; /** - * Maps each element to a stream and concatenates the results in order. + * Maps each element to a stream and flattens the resulting streams. + * + * **Details** + * + * With the default sequential concurrency, inner streams are concatenated in + * input order. When `concurrency` is greater than `1` or `"unbounded"`, + * multiple inner streams may run at the same time and their outputs are merged + * as they arrive. + * + * **Example** (FlatMapping stream values) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2407,8 +2522,8 @@ export declare const flatMap: { * // Output: [ 1, 2, 2, 4, 3, 6 ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ (self: Stream, f: (a: A) => Stream, options?: { readonly concurrency?: number | "unbounded" | undefined; @@ -2419,7 +2534,8 @@ export declare const flatMap: { * Switches to the latest stream produced by the mapping function, interrupting * the previous stream when a new element arrives. * - * @example + * **Example** (Switching to the latest stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2435,15 +2551,16 @@ export declare const flatMap: { * }) * ``` * + * @category sequencing * @since 4.0.0 - * @category Sequencing */ export declare const switchMap: { /** * Switches to the latest stream produced by the mapping function, interrupting * the previous stream when a new element arrives. * - * @example + * **Example** (Switching to the latest stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2459,8 +2576,8 @@ export declare const switchMap: { * }) * ``` * + * @category sequencing * @since 4.0.0 - * @category Sequencing */ (f: (a: A) => Stream, options?: { readonly concurrency?: number | "unbounded" | undefined; @@ -2470,7 +2587,8 @@ export declare const switchMap: { * Switches to the latest stream produced by the mapping function, interrupting * the previous stream when a new element arrives. * - * @example + * **Example** (Switching to the latest stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2486,8 +2604,8 @@ export declare const switchMap: { * }) * ``` * + * @category sequencing * @since 4.0.0 - * @category Sequencing */ (self: Stream, f: (a: A) => Stream, options?: { readonly concurrency?: number | "unbounded" | undefined; @@ -2495,10 +2613,17 @@ export declare const switchMap: { } | undefined): Stream; }; /** - * Flattens a stream of streams into a single stream by concatenating the - * inner streams in strict order. + * Flattens a stream of streams into a single stream. + * + * **Details** + * + * With the default sequential concurrency, inner streams are concatenated in + * strict order. When `concurrency` is greater than `1` or `"unbounded"`, + * multiple inner streams may run at the same time and their outputs are merged + * as they arrive. + * + * **Example** (Flattening nested streams) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2517,8 +2642,8 @@ export declare const switchMap: { * // Output: [ 1, 2, 3, 4, 5, 6 ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ export declare const flatten: , any, any> | { readonly concurrency?: number | "unbounded" | undefined; @@ -2533,13 +2658,8 @@ export declare const flatten: , any, an /** * Flattens a stream of non-empty arrays into a stream of elements. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: - * - * - `Stream.flattenChunks` + * **Example** (Flattening a stream of non-empty arrays into a stream of elements) * - * @example * ```ts * import { Array, Console, Effect, Stream } from "effect" * @@ -2554,14 +2674,15 @@ export declare const flatten: , any, an * // Output: [ 1, 2, 3 ] * ``` * + * @category sequencing * @since 4.0.0 - * @category Sequencing */ export declare const flattenArray: (self: Stream, E, R>) => Stream; /** * Converts this stream to one that runs its effects but emits no elements. * - * @example + * **Example** (Draining stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2574,15 +2695,16 @@ export declare const flattenArray: (self: Stream(self: Stream) => Stream; /** * Runs the provided stream in the background while this stream runs, interrupting it * when this stream completes and failing if the background stream fails or defects. * - * @example + * **Example** (Draining a stream in the background) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2602,15 +2724,16 @@ export declare const drain: (self: Stream) => Stream(that: Stream): (self: Stream) => Stream; /** * Runs the provided stream in the background while this stream runs, interrupting it * when this stream completes and failing if the background stream fails or defects. * - * @example + * **Example** (Draining a stream in the background) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2658,15 +2782,16 @@ export declare const drainFork: { * // Output: [ 1, 2 ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (self: Stream, that: Stream): Stream; }; /** * Repeats the entire stream according to the provided schedule. * - * @example + * **Example** (Repeating a stream on a schedule) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -2683,14 +2808,15 @@ export declare const drainFork: { * // Output: [ 1, 1, 1, 1, 1 ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ export declare const repeat: { /** * Repeats the entire stream according to the provided schedule. * - * @example + * **Example** (Repeating a stream on a schedule) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -2707,14 +2833,15 @@ export declare const repeat: { * // Output: [ 1, 1, 1, 1, 1 ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (schedule: Schedule.Schedule | (($: (_: Schedule.Schedule) => Schedule.Schedule) => Schedule.Schedule)): (self: Stream) => Stream; /** * Repeats the entire stream according to the provided schedule. * - * @example + * **Example** (Repeating a stream on a schedule) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -2731,15 +2858,16 @@ export declare const repeat: { * // Output: [ 1, 1, 1, 1, 1 ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (self: Stream, schedule: Schedule.Schedule | (($: (_: Schedule.Schedule) => Schedule.Schedule) => Schedule.Schedule)): Stream; }; /** - * Spaces the stream's elements according to the provided `schedule`. + * Schedules the stream's elements according to the provided schedule. + * + * **Example** (Scheduling stream elements) * - * @example * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -2756,14 +2884,15 @@ export declare const repeat: { * // Output: [ 1, 2, 3 ] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ export declare const schedule: { /** - * Spaces the stream's elements according to the provided `schedule`. + * Schedules the stream's elements according to the provided schedule. + * + * **Example** (Scheduling stream elements) * - * @example * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -2780,14 +2909,15 @@ export declare const schedule: { * // Output: [ 1, 2, 3 ] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (schedule: Schedule.Schedule, E2, R2>): (self: Stream) => Stream; /** - * Spaces the stream's elements according to the provided `schedule`. + * Schedules the stream's elements according to the provided schedule. + * + * **Example** (Scheduling stream elements) * - * @example * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -2804,15 +2934,16 @@ export declare const schedule: { * // Output: [ 1, 2, 3 ] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (self: Stream, schedule: Schedule.Schedule, E2, R2>): Stream; }; /** * Ends the stream if it does not produce a value within the specified duration. * - * @example + * **Example** (Timing out a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2829,14 +2960,15 @@ export declare const schedule: { * // Output: [ 1 ] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ export declare const timeout: { /** * Ends the stream if it does not produce a value within the specified duration. * - * @example + * **Example** (Timing out a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2853,14 +2985,15 @@ export declare const timeout: { * // Output: [ 1 ] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (duration: Duration.Input): (self: Stream) => Stream; /** * Ends the stream if it does not produce a value within the specified duration. * - * @example + * **Example** (Timing out a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2877,27 +3010,87 @@ export declare const timeout: { * // Output: [ 1 ] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (self: Stream, duration: Duration.Input): Stream; }; /** - * @since 2.0.0 - * @category Rate Limiting + * Switches to a fallback stream if this stream does not emit a value within + * the specified duration. + * + * **When to use** + * + * Use when a stream should continue with another stream if an upstream pull + * waits longer than the allowed duration. + * + * **Details** + * + * The timeout is checked for each pull. A zero duration uses `orElse` + * immediately, while an infinite duration leaves the original stream + * unchanged. + * + * **Gotchas** + * + * The fallback stream is not timed after the switch. + * + * @see {@link timeout} for ending the stream instead of switching to a fallback stream + * + * @category rate limiting + * @since 4.0.0 */ export declare const timeoutOrElse: { /** - * @since 2.0.0 - * @category Rate Limiting + * Switches to a fallback stream if this stream does not emit a value within + * the specified duration. + * + * **When to use** + * + * Use when a stream should continue with another stream if an upstream pull + * waits longer than the allowed duration. + * + * **Details** + * + * The timeout is checked for each pull. A zero duration uses `orElse` + * immediately, while an infinite duration leaves the original stream + * unchanged. + * + * **Gotchas** + * + * The fallback stream is not timed after the switch. + * + * @see {@link timeout} for ending the stream instead of switching to a fallback stream + * + * @category rate limiting + * @since 4.0.0 */ (options: { readonly duration: Duration.Input; readonly orElse: () => Stream; }): (self: Stream) => Stream; /** - * @since 2.0.0 - * @category Rate Limiting + * Switches to a fallback stream if this stream does not emit a value within + * the specified duration. + * + * **When to use** + * + * Use when a stream should continue with another stream if an upstream pull + * waits longer than the allowed duration. + * + * **Details** + * + * The timeout is checked for each pull. A zero duration uses `orElse` + * immediately, while an infinite duration leaves the original stream + * unchanged. + * + * **Gotchas** + * + * The fallback stream is not timed after the switch. + * + * @see {@link timeout} for ending the stream instead of switching to a fallback stream + * + * @category rate limiting + * @since 4.0.0 */ (self: Stream, options: { readonly duration: Duration.Input; @@ -2908,9 +3101,8 @@ export declare const timeoutOrElse: { * Repeats each element of the stream according to the provided schedule, * including the original emission. * - * @since 2.0.0 - * @category Sequencing - * @example + * **Example** (Repeating stream elements) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -2925,15 +3117,17 @@ export declare const timeoutOrElse: { * Effect.runPromise(program) * // Output: [ "A", "A", "B", "B", "C", "C" ] * ``` + * + * @category sequencing + * @since 2.0.0 */ export declare const repeatElements: { /** * Repeats each element of the stream according to the provided schedule, * including the original emission. * - * @since 2.0.0 - * @category Sequencing - * @example + * **Example** (Repeating stream elements) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -2948,15 +3142,17 @@ export declare const repeatElements: { * Effect.runPromise(program) * // Output: [ "A", "A", "B", "B", "C", "C" ] * ``` + * + * @category sequencing + * @since 2.0.0 */ (schedule: Schedule.Schedule): (self: Stream) => Stream; /** * Repeats each element of the stream according to the provided schedule, * including the original emission. * - * @since 2.0.0 - * @category Sequencing - * @example + * **Example** (Repeating stream elements) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -2971,13 +3167,17 @@ export declare const repeatElements: { * Effect.runPromise(program) * // Output: [ "A", "A", "B", "B", "C", "C" ] * ``` + * + * @category sequencing + * @since 2.0.0 */ (self: Stream, schedule: Schedule.Schedule): Stream; }; /** * Repeats this stream forever. * - * @example + * **Example** (Repeating a stream forever) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -2995,20 +3195,15 @@ export declare const repeatElements: { * // Output: [ "A", "B", "A", "B", "A" ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ export declare const forever: (self: Stream) => Stream; /** - * Submerges the iterables emitted by this stream into the stream's structure. + * Flattens the iterables emitted by this stream into the stream's structure. * - * **Previously Known As** + * **Example** (Flattening iterable values) * - * This API replaces the following from Effect 3.x: - * - * - `Stream.flattenIterables` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3022,15 +3217,16 @@ export declare const forever: (self: Stream) => Stream(self: Stream, E, R>) => Stream; /** * Unwraps `Take` values, emitting elements from non-empty arrays and ending or * failing when the `Exit` signals completion. * - * @example + * **Example** (Flattening Take values) + * * ```ts * import { Array, Console, Effect, Exit, Stream } from "effect" * @@ -3049,15 +3245,16 @@ export declare const flattenIterable: (self: Stream, E, R>) * // Output: [ 1, 2, 3 ] * ``` * - * @since 4.0.0 - * @category Sequencing + * @category sequencing + * @since 2.0.0 */ export declare const flattenTake: (self: Stream, E2, R>) => Stream; /** * Concatenates two streams, emitting all elements from the first stream * followed by all elements from the second stream. * - * @example + * **Example** (Concatenating streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3070,15 +3267,16 @@ export declare const flattenTake: (self: Stream, E2 * // Output: [ 1, 2, 3, 4, 5, 6 ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ export declare const concat: { /** * Concatenates two streams, emitting all elements from the first stream * followed by all elements from the second stream. * - * @example + * **Example** (Concatenating streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3091,15 +3289,16 @@ export declare const concat: { * // Output: [ 1, 2, 3, 4, 5, 6 ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (that: Stream): (self: Stream) => Stream; /** * Concatenates two streams, emitting all elements from the first stream * followed by all elements from the second stream. * - * @example + * **Example** (Concatenating streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3112,15 +3311,16 @@ export declare const concat: { * // Output: [ 1, 2, 3, 4, 5, 6 ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (self: Stream, that: Stream): Stream; }; /** * Prepends the values from the provided iterable before the stream's elements. * - * @example + * **Example** (Prepending values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3137,14 +3337,15 @@ export declare const concat: { * Effect.runPromise(program) * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ export declare const prepend: { /** * Prepends the values from the provided iterable before the stream's elements. * - * @example + * **Example** (Prepending values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3161,14 +3362,15 @@ export declare const prepend: { * Effect.runPromise(program) * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (values: Iterable): (self: Stream) => Stream; /** * Prepends the values from the provided iterable before the stream's elements. * - * @example + * **Example** (Prepending values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3185,18 +3387,21 @@ export declare const prepend: { * Effect.runPromise(program) * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (self: Stream, values: Iterable): Stream; }; /** * Merges two streams, emitting elements from both as they arrive. * + * **Details** + * * By default, the merged stream ends when both streams end. Use * `haltStrategy` to change the termination behavior. * - * @example + * **Example** (Merging stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3212,17 +3417,20 @@ export declare const prepend: { * // Output: [ 1, 2, 3, 4 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ export declare const merge: { /** * Merges two streams, emitting elements from both as they arrive. * + * **Details** + * * By default, the merged stream ends when both streams end. Use * `haltStrategy` to change the termination behavior. * - * @example + * **Example** (Merging stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3238,8 +3446,8 @@ export declare const merge: { * // Output: [ 1, 2, 3, 4 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ (that: Stream, options?: { readonly haltStrategy?: HaltStrategy | undefined; @@ -3247,10 +3455,13 @@ export declare const merge: { /** * Merges two streams, emitting elements from both as they arrive. * + * **Details** + * * By default, the merged stream ends when both streams end. Use * `haltStrategy` to change the termination behavior. * - * @example + * **Example** (Merging stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3266,8 +3477,8 @@ export declare const merge: { * // Output: [ 1, 2, 3, 4 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ (self: Stream, that: Stream, options?: { readonly haltStrategy?: HaltStrategy | undefined; @@ -3276,12 +3487,18 @@ export declare const merge: { /** * Merges this stream with a background effect, keeping the stream's elements. * + * **When to use** + * + * Use when an effect should run concurrently for the lifetime of a stream while + * only the stream's elements remain in the output. + * + * **Details** + * * The effect runs concurrently, fails the stream if it fails, and is interrupted * when the stream completes. * - * @since 4.0.0 - * @category Merging - * @example + * **Example** (Merging with a background effect) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3298,17 +3515,26 @@ export declare const merge: { * // Output: side task * // Output: [ 1, 2, 3 ] * ``` + * + * @category merging + * @since 4.0.0 */ export declare const mergeEffect: { /** * Merges this stream with a background effect, keeping the stream's elements. * + * **When to use** + * + * Use when an effect should run concurrently for the lifetime of a stream while + * only the stream's elements remain in the output. + * + * **Details** + * * The effect runs concurrently, fails the stream if it fails, and is interrupted * when the stream completes. * - * @since 4.0.0 - * @category Merging - * @example + * **Example** (Merging with a background effect) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3325,17 +3551,26 @@ export declare const mergeEffect: { * // Output: side task * // Output: [ 1, 2, 3 ] * ``` + * + * @category merging + * @since 4.0.0 */ (effect: Effect.Effect): (self: Stream) => Stream; /** * Merges this stream with a background effect, keeping the stream's elements. * + * **When to use** + * + * Use when an effect should run concurrently for the lifetime of a stream while + * only the stream's elements remain in the output. + * + * **Details** + * * The effect runs concurrently, fails the stream if it fails, and is interrupted * when the stream completes. * - * @since 4.0.0 - * @category Merging - * @example + * **Example** (Merging with a background effect) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3352,6 +3587,9 @@ export declare const mergeEffect: { * // Output: side task * // Output: [ 1, 2, 3 ] * ``` + * + * @category merging + * @since 4.0.0 */ (self: Stream, effect: Effect.Effect): Stream; }; @@ -3359,13 +3597,14 @@ export declare const mergeEffect: { * Merges this stream and the specified stream together, tagging values from the * left stream as `Result.succeed` and values from the right stream as `Result.fail`. * - * **Previously Known As** + * **When to use** * - * This API replaces the following from Effect 3.x: + * Use when values from both streams should be emitted and downstream code needs + * left values wrapped as successful `Result` values and right values wrapped as + * failed `Result` values. * - * - `Stream.mergeEither` + * **Example** (Merging streams into results) * - * @example * ```ts * import { Console, Effect, Result, Stream } from "effect" * @@ -3391,21 +3630,22 @@ export declare const mergeEffect: { * // Output: [ "left:left", "right:right" ] * ``` * - * @since 2.0.0 - * @category Merging + * @category merging + * @since 4.0.0 */ export declare const mergeResult: { /** * Merges this stream and the specified stream together, tagging values from the * left stream as `Result.succeed` and values from the right stream as `Result.fail`. * - * **Previously Known As** + * **When to use** * - * This API replaces the following from Effect 3.x: + * Use when values from both streams should be emitted and downstream code needs + * left values wrapped as successful `Result` values and right values wrapped as + * failed `Result` values. * - * - `Stream.mergeEither` + * **Example** (Merging streams into results) * - * @example * ```ts * import { Console, Effect, Result, Stream } from "effect" * @@ -3431,21 +3671,22 @@ export declare const mergeResult: { * // Output: [ "left:left", "right:right" ] * ``` * - * @since 2.0.0 - * @category Merging + * @category merging + * @since 4.0.0 */ (that: Stream): (self: Stream) => Stream, E2 | E, R2 | R>; /** * Merges this stream and the specified stream together, tagging values from the * left stream as `Result.succeed` and values from the right stream as `Result.fail`. * - * **Previously Known As** + * **When to use** * - * This API replaces the following from Effect 3.x: + * Use when values from both streams should be emitted and downstream code needs + * left values wrapped as successful `Result` values and right values wrapped as + * failed `Result` values. * - * - `Stream.mergeEither` + * **Example** (Merging streams into results) * - * @example * ```ts * import { Console, Effect, Result, Stream } from "effect" * @@ -3471,19 +3712,27 @@ export declare const mergeResult: { * // Output: [ "left:left", "right:right" ] * ``` * - * @since 2.0.0 - * @category Merging + * @category merging + * @since 4.0.0 */ (self: Stream, that: Stream): Stream, E | E2, R | R2>; }; /** * Merges two streams while emitting only the values from the left stream. * + * **When to use** + * + * Use when the right stream is needed for its effects or failures, but downstream + * consumers should only receive values from the left stream. + * + * **Details** + * * The right stream still runs for its effects, and any failures from the right * stream are propagated. The merged stream completes when the left stream * completes, interrupting the right stream. * - * @example + * **Example** (Merging streams while keeping left values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3498,18 +3747,26 @@ export declare const mergeResult: { * // Output: [ 1, 2 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ export declare const mergeLeft: { /** * Merges two streams while emitting only the values from the left stream. * + * **When to use** + * + * Use when the right stream is needed for its effects or failures, but downstream + * consumers should only receive values from the left stream. + * + * **Details** + * * The right stream still runs for its effects, and any failures from the right * stream are propagated. The merged stream completes when the left stream * completes, interrupting the right stream. * - * @example + * **Example** (Merging streams while keeping left values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3524,18 +3781,26 @@ export declare const mergeLeft: { * // Output: [ 1, 2 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ (right: Stream): (left: Stream) => Stream; /** * Merges two streams while emitting only the values from the left stream. * + * **When to use** + * + * Use when the right stream is needed for its effects or failures, but downstream + * consumers should only receive values from the left stream. + * + * **Details** + * * The right stream still runs for its effects, and any failures from the right * stream are propagated. The merged stream completes when the left stream * completes, interrupting the right stream. * - * @example + * **Example** (Merging streams while keeping left values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3550,8 +3815,8 @@ export declare const mergeLeft: { * // Output: [ 1, 2 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ (left: Stream, right: Stream): Stream; }; @@ -3559,10 +3824,18 @@ export declare const mergeLeft: { * Merges this stream and the specified stream together, emitting only the * values from the right stream while the left stream runs for its effects. * + * **When to use** + * + * Use when the left stream is needed for its effects or failures, but downstream + * consumers should only receive values from the right stream. + * + * **Details** + * * The merged stream ends when the right stream completes, interrupting the * left stream. Failures from the left stream still fail the merged stream. * - * @example + * **Example** (Merging streams while keeping right values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3582,18 +3855,26 @@ export declare const mergeLeft: { * // Output: [ 1, 2 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ export declare const mergeRight: { /** * Merges this stream and the specified stream together, emitting only the * values from the right stream while the left stream runs for its effects. * + * **When to use** + * + * Use when the left stream is needed for its effects or failures, but downstream + * consumers should only receive values from the right stream. + * + * **Details** + * * The merged stream ends when the right stream completes, interrupting the * left stream. Failures from the left stream still fail the merged stream. * - * @example + * **Example** (Merging streams while keeping right values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3613,18 +3894,26 @@ export declare const mergeRight: { * // Output: [ 1, 2 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ (right: Stream): (left: Stream) => Stream; /** * Merges this stream and the specified stream together, emitting only the * values from the right stream while the left stream runs for its effects. * + * **When to use** + * + * Use when the left stream is needed for its effects or failures, but downstream + * consumers should only receive values from the right stream. + * + * **Details** + * * The merged stream ends when the right stream completes, interrupting the * left stream. Failures from the left stream still fail the merged stream. * - * @example + * **Example** (Merging streams while keeping right values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3644,18 +3933,27 @@ export declare const mergeRight: { * // Output: [ 1, 2 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ (left: Stream, right: Stream): Stream; }; /** * Merges a collection of streams, running up to the specified number concurrently. * - * @since 2.0.0 - * @category Merging + * **When to use** + * + * Use to merge an iterable of already-created streams while bounding how many + * inner streams may run at the same time. + * + * **Details** + * + * The `concurrency` option is required and may be a number or `"unbounded"`. + * `bufferSize` controls buffering between inner streams, and outputs are + * emitted as they arrive under concurrent merging. + * + * **Example** (Merging streams with bounded concurrency) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3674,15 +3972,30 @@ export declare const mergeRight: { * Effect.runPromise(program) * // Output: [ "B", "A" ] * ``` + * + * @see {@link merge} for merging exactly two streams and choosing a halt strategy + * @see {@link flatten} for flattening a stream that already emits streams + * + * @category merging + * @since 2.0.0 */ export declare const mergeAll: { /** * Merges a collection of streams, running up to the specified number concurrently. * - * @since 2.0.0 - * @category Merging + * **When to use** + * + * Use to merge an iterable of already-created streams while bounding how many + * inner streams may run at the same time. + * + * **Details** + * + * The `concurrency` option is required and may be a number or `"unbounded"`. + * `bufferSize` controls buffering between inner streams, and outputs are + * emitted as they arrive under concurrent merging. + * + * **Example** (Merging streams with bounded concurrency) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3701,6 +4014,12 @@ export declare const mergeAll: { * Effect.runPromise(program) * // Output: [ "B", "A" ] * ``` + * + * @see {@link merge} for merging exactly two streams and choosing a halt strategy + * @see {@link flatten} for flattening a stream that already emits streams + * + * @category merging + * @since 2.0.0 */ (options: { readonly concurrency: number | "unbounded"; @@ -3709,10 +4028,19 @@ export declare const mergeAll: { /** * Merges a collection of streams, running up to the specified number concurrently. * - * @since 2.0.0 - * @category Merging + * **When to use** + * + * Use to merge an iterable of already-created streams while bounding how many + * inner streams may run at the same time. + * + * **Details** + * + * The `concurrency` option is required and may be a number or `"unbounded"`. + * `bufferSize` controls buffering between inner streams, and outputs are + * emitted as they arrive under concurrent merging. + * + * **Example** (Merging streams with bounded concurrency) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3731,6 +4059,12 @@ export declare const mergeAll: { * Effect.runPromise(program) * // Output: [ "B", "A" ] * ``` + * + * @see {@link merge} for merging exactly two streams and choosing a halt strategy + * @see {@link flatten} for flattening a stream that already emits streams + * + * @category merging + * @since 2.0.0 */ (streams: Iterable>, options: { readonly concurrency: number | "unbounded"; @@ -3741,9 +4075,12 @@ export declare const mergeAll: { * Creates the cartesian product of two streams, running the `right` stream for * each element in the `left` stream. * + * **Details** + * * See also `Stream.zip` for the more common point-wise variant. * - * @example + * **Example** (Computing cartesian products) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3758,17 +4095,20 @@ export declare const mergeAll: { * // Output: [ [ 1, "a" ], [ 1, "b" ], [ 2, "a" ], [ 2, "b" ] ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const cross: { /** * Creates the cartesian product of two streams, running the `right` stream for * each element in the `left` stream. * + * **Details** + * * See also `Stream.zip` for the more common point-wise variant. * - * @example + * **Example** (Computing cartesian products) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3783,17 +4123,20 @@ export declare const cross: { * // Output: [ [ 1, "a" ], [ 1, "b" ], [ 2, "a" ], [ 2, "b" ] ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (right: Stream): (left: Stream) => Stream<[AL, AR], EL | ER, RL | RR>; /** * Creates the cartesian product of two streams, running the `right` stream for * each element in the `left` stream. * + * **Details** + * * See also `Stream.zip` for the more common point-wise variant. * - * @example + * **Example** (Computing cartesian products) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3808,19 +4151,22 @@ export declare const cross: { * // Output: [ [ 1, "a" ], [ 1, "b" ], [ 2, "a" ], [ 2, "b" ] ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (left: Stream, right: Stream): Stream<[AL, AR], EL | ER, RL | RR>; }; /** * Creates a cartesian product of elements from two streams using a function. * + * **Details** + * * The `right` stream is rerun for every element in the `left` stream. * * See also `Stream.zipWith` for the more common point-wise variant. * - * @example + * **Example** (Combining cartesian products) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3836,18 +4182,21 @@ export declare const cross: { * // Output: [ "1-a", "1-b", "2-a", "2-b" ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const crossWith: { /** * Creates a cartesian product of elements from two streams using a function. * + * **Details** + * * The `right` stream is rerun for every element in the `left` stream. * * See also `Stream.zipWith` for the more common point-wise variant. * - * @example + * **Example** (Combining cartesian products) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3863,18 +4212,21 @@ export declare const crossWith: { * // Output: [ "1-a", "1-b", "2-a", "2-b" ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (right: Stream, f: (left: AL, right: AR) => A): (left: Stream) => Stream; /** * Creates a cartesian product of elements from two streams using a function. * + * **Details** + * * The `right` stream is rerun for every element in the `left` stream. * * See also `Stream.zipWith` for the more common point-wise variant. * - * @example + * **Example** (Combining cartesian products) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3890,15 +4242,16 @@ export declare const crossWith: { * // Output: [ "1-a", "1-b", "2-a", "2-b" ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (left: Stream, right: Stream, f: (left: AL, right: AR) => A): Stream; }; /** * Zips two streams point-wise with a combining function, ending when either stream ends. * - * @example + * **Example** (Zipping streams with a function) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3916,14 +4269,15 @@ export declare const crossWith: { * // Output: [ "1-a", "2-b", "3-c" ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const zipWith: { /** * Zips two streams point-wise with a combining function, ending when either stream ends. * - * @example + * **Example** (Zipping streams with a function) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3941,14 +4295,15 @@ export declare const zipWith: { * // Output: [ "1-a", "2-b", "3-c" ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (right: Stream, f: (left: AL, right: AR) => A): (left: Stream) => Stream; /** * Zips two streams point-wise with a combining function, ending when either stream ends. * - * @example + * **Example** (Zipping streams with a function) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -3966,23 +4321,20 @@ export declare const zipWith: { * // Output: [ "1-a", "2-b", "3-c" ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (left: Stream, right: Stream, f: (left: AL, right: AR) => A): Stream; }; /** * Zips two streams by applying a function to non-empty arrays of elements. * - * The function returns output plus leftover arrays that carry into the next pull. - * - * **Previously Known As** + * **Details** * - * This API replaces the following from Effect 3.x: + * The function returns output plus leftover arrays that carry into the next pull. * - * - `Stream.zipWithChunks` + * **Example** (Zipping stream chunks) * - * @example * ```ts * import { Array, Console, Effect, Stream } from "effect" * @@ -4005,22 +4357,19 @@ export declare const zipWith: { * // Output: [[1, "a"], [2, "b"], [3, "c"], [4, "d"], [5, "e"]] * ``` * - * @since 2.0.0 - * @category Zipping + * @category zipping + * @since 4.0.0 */ export declare const zipWithArray: { /** * Zips two streams by applying a function to non-empty arrays of elements. * - * The function returns output plus leftover arrays that carry into the next pull. - * - * **Previously Known As** + * **Details** * - * This API replaces the following from Effect 3.x: + * The function returns output plus leftover arrays that carry into the next pull. * - * - `Stream.zipWithChunks` + * **Example** (Zipping stream chunks) * - * @example * ```ts * import { Array, Console, Effect, Stream } from "effect" * @@ -4043,8 +4392,8 @@ export declare const zipWithArray: { * // Output: [[1, "a"], [2, "b"], [3, "c"], [4, "d"], [5, "e"]] * ``` * - * @since 2.0.0 - * @category Zipping + * @category zipping + * @since 4.0.0 */ (right: Stream, f: (left: Arr.NonEmptyReadonlyArray, right: Arr.NonEmptyReadonlyArray) => readonly [ output: Arr.NonEmptyReadonlyArray, @@ -4054,15 +4403,12 @@ export declare const zipWithArray: { /** * Zips two streams by applying a function to non-empty arrays of elements. * - * The function returns output plus leftover arrays that carry into the next pull. - * - * **Previously Known As** + * **Details** * - * This API replaces the following from Effect 3.x: + * The function returns output plus leftover arrays that carry into the next pull. * - * - `Stream.zipWithChunks` + * **Example** (Zipping stream chunks) * - * @example * ```ts * import { Array, Console, Effect, Stream } from "effect" * @@ -4085,8 +4431,8 @@ export declare const zipWithArray: { * // Output: [[1, "a"], [2, "b"], [3, "c"], [4, "d"], [5, "e"]] * ``` * - * @since 2.0.0 - * @category Zipping + * @category zipping + * @since 4.0.0 */ (left: Stream, right: Stream, f: (left: Arr.NonEmptyReadonlyArray, right: Arr.NonEmptyReadonlyArray) => readonly [ output: Arr.NonEmptyReadonlyArray, @@ -4098,7 +4444,8 @@ export declare const zipWithArray: { * Zips this stream with another point-wise and emits tuples of elements from * both streams. The new stream ends when either stream ends. * - * @example + * **Example** (Zipping streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4116,15 +4463,16 @@ export declare const zipWithArray: { * // Output: [[1, "a"], [2, "b"], [3, "c"]] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const zip: { /** * Zips this stream with another point-wise and emits tuples of elements from * both streams. The new stream ends when either stream ends. * - * @example + * **Example** (Zipping streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4142,15 +4490,16 @@ export declare const zip: { * // Output: [[1, "a"], [2, "b"], [3, "c"]] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (that: Stream): (self: Stream) => Stream<[A, A2], E2 | E, R2 | R>; /** * Zips this stream with another point-wise and emits tuples of elements from * both streams. The new stream ends when either stream ends. * - * @example + * **Example** (Zipping streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4168,8 +4517,8 @@ export declare const zip: { * // Output: [[1, "a"], [2, "b"], [3, "c"]] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (self: Stream, that: Stream): Stream<[A, A2], E | E2, R | R2>; }; @@ -4177,9 +4526,12 @@ export declare const zip: { * Zips this stream with another point-wise and keeps only the values from * the left stream. * + * **Details** + * * The resulting stream ends when either side ends. * - * @example + * **Example** (Zipping streams while keeping left values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4195,17 +4547,20 @@ export declare const zip: { * // Output: [1, 2] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const zipLeft: { /** * Zips this stream with another point-wise and keeps only the values from * the left stream. * + * **Details** + * * The resulting stream ends when either side ends. * - * @example + * **Example** (Zipping streams while keeping left values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4221,17 +4576,20 @@ export declare const zipLeft: { * // Output: [1, 2] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (right: Stream): (left: Stream) => Stream; /** * Zips this stream with another point-wise and keeps only the values from * the left stream. * + * **Details** + * * The resulting stream ends when either side ends. * - * @example + * **Example** (Zipping streams while keeping left values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4247,15 +4605,16 @@ export declare const zipLeft: { * // Output: [1, 2] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (left: Stream, right: Stream): Stream; }; /** * Zips this stream with another point-wise, keeping only right values and ending when either stream ends. * - * @example + * **Example** (Zipping streams while keeping right values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4271,14 +4630,15 @@ export declare const zipLeft: { * // Output: ["a", "b"] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const zipRight: { /** * Zips this stream with another point-wise, keeping only right values and ending when either stream ends. * - * @example + * **Example** (Zipping streams while keeping right values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4294,14 +4654,15 @@ export declare const zipRight: { * // Output: ["a", "b"] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (right: Stream): (left: Stream) => Stream; /** * Zips this stream with another point-wise, keeping only right values and ending when either stream ends. * - * @example + * **Example** (Zipping streams while keeping right values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4317,8 +4678,8 @@ export declare const zipRight: { * // Output: ["a", "b"] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (left: Stream, right: Stream): Stream; }; @@ -4326,9 +4687,12 @@ export declare const zipRight: { * Zips this stream with another point-wise and emits tuples of elements from * both streams, flattening the left tuple. * + * **Details** + * * The new stream will end when one of the sides ends. * - * @example + * **Example** (Zipping and flattening tuples) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4348,17 +4712,20 @@ export declare const zipRight: { * // Output: [[1, "a", "x"], [2, "b", "y"], [3, "c", "z"]] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const zipFlatten: { /** * Zips this stream with another point-wise and emits tuples of elements from * both streams, flattening the left tuple. * + * **Details** + * * The new stream will end when one of the sides ends. * - * @example + * **Example** (Zipping and flattening tuples) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4378,17 +4745,20 @@ export declare const zipFlatten: { * // Output: [[1, "a", "x"], [2, "b", "y"], [3, "c", "z"]] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (that: Stream): , E, R>(self: Stream) => Stream<[...A, A2], E2 | E, R2 | R>; /** * Zips this stream with another point-wise and emits tuples of elements from * both streams, flattening the left tuple. * + * **Details** + * * The new stream will end when one of the sides ends. * - * @example + * **Example** (Zipping and flattening tuples) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4408,15 +4778,16 @@ export declare const zipFlatten: { * // Output: [[1, "a", "x"], [2, "b", "y"], [3, "c", "z"]] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ , E, R, A2, E2, R2>(self: Stream, that: Stream): Stream<[...A, A2], E | E2, R | R2>; }; /** * Zips this stream together with the index of elements. * - * @example + * **Example** (Zipping elements with indices) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4432,15 +4803,16 @@ export declare const zipFlatten: { * // Output: [["a", 0], ["b", 1], ["c", 2], ["d", 3]] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const zipWithIndex: (self: Stream) => Stream<[A, number], E, R>; /** * Zips each element with the next element, pairing the final element with * `Option.none()`. * - * @example + * **Example** (Zipping elements with next values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4458,14 +4830,15 @@ export declare const zipWithIndex: (self: Stream) => Stream<[A * // ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const zipWithNext: (self: Stream) => Stream<[A, Option.Option], E, R>; /** * Zips each element with its previous element, starting with `None`. * - * @example + * **Example** (Zipping elements with previous values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4485,14 +4858,15 @@ export declare const zipWithNext: (self: Stream) => Stream<[A, * // ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const zipWithPrevious: (self: Stream) => Stream<[Option.Option, A], E, R>; /** * Zips each element with its previous and next values. * - * @example + * **Example** (Zipping elements with neighbors) + * * ```ts * import { Console, Effect, Option, Stream } from "effect" * @@ -4508,19 +4882,27 @@ export declare const zipWithPrevious: (self: Stream) => Stream * // Output: [ [Option.none(), 1, Option.some(2)], [Option.some(1), 2, Option.some(3)], [Option.some(2), 3, Option.none()] ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const zipWithPreviousAndNext: (self: Stream) => Stream<[Option.Option, A, Option.Option], E, R>; /** * Zips multiple streams so that when a value is emitted by any stream, it is * combined with the latest values from the other streams to produce a result. * + * **When to use** + * + * Use when each stream should contribute its latest value after all streams have + * emitted at least once. + * + * **Gotchas** + * * Note: tracking the latest value is done on a per-array basis. That means * that emitted elements that are not the last value in arrays will never be * used for zipping. * - * @example + * **Example** (Zipping latest values from many streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4539,18 +4921,26 @@ export declare const zipWithPreviousAndNext: (self: Stream) => * // Output: [ [ 1, "a", true ], [ 2, "a", true ], [ 3, "a", true ], [ 3, "b", true ], [ 3, "c", true ], [ 3, "c", false ], [ 3, "c", true ] ] * ``` * - * @since 2.0.0 - * @category Zipping + * @category zipping + * @since 3.3.0 */ export declare const zipLatestAll: >>(...streams: T) => Stream<[T[number]] extends [never] ? never : { [K in keyof T]: T[K] extends Stream ? A : never; }, [T[number]] extends [never] ? never : T[number] extends Stream ? _E_1 : never, [T[number]] extends [never] ? never : T[number] extends Stream ? _R_2 : never>; /** * Combines two streams by emitting each new element with the latest value from the other stream. * + * **When to use** + * + * Use when two streams should start emitting combined pairs after both have + * produced at least one value. + * + * **Gotchas** + * * Note: tracking the latest value is done on a per-array basis. That means * that emitted elements that are not the last value in arrays will never be * used for zipping. * - * @example + * **Example** (Zipping latest values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4565,18 +4955,26 @@ export declare const zipLatestAll: (right: Stream): (left: Stream) => Stream<[AL, AR], EL | ER, RL | RR>; /** * Combines two streams by emitting each new element with the latest value from the other stream. * + * **When to use** + * + * Use when two streams should start emitting combined pairs after both have + * produced at least one value. + * + * **Gotchas** + * * Note: tracking the latest value is done on a per-array basis. That means * that emitted elements that are not the last value in arrays will never be * used for zipping. * - * @example + * **Example** (Zipping latest values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4617,8 +5023,8 @@ export declare const zipLatest: { * // Output: [ [1, "a"] ] * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (left: Stream, right: Stream): Stream<[AL, AR], EL | ER, RL | RR>; }; @@ -4626,11 +5032,19 @@ export declare const zipLatest: { * Combines the latest values from both streams whenever either emits, using * the provided function. * + * **When to use** + * + * Use when two streams should start emitting custom combined values after both + * have produced at least one value. + * + * **Gotchas** + * * Note: tracking the latest value is done on a per-array basis. That means * that emitted elements that are not the last value in arrays will never be * used for zipping. * - * @example + * **Example** (Zipping latest values with a function) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4649,19 +5063,27 @@ export declare const zipLatest: { * }) * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ export declare const zipLatestWith: { /** * Combines the latest values from both streams whenever either emits, using * the provided function. * + * **When to use** + * + * Use when two streams should start emitting custom combined values after both + * have produced at least one value. + * + * **Gotchas** + * * Note: tracking the latest value is done on a per-array basis. That means * that emitted elements that are not the last value in arrays will never be * used for zipping. * - * @example + * **Example** (Zipping latest values with a function) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4680,19 +5102,27 @@ export declare const zipLatestWith: { * }) * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (right: Stream, f: (left: AL, right: AR) => A): (left: Stream) => Stream; /** * Combines the latest values from both streams whenever either emits, using * the provided function. * + * **When to use** + * + * Use when two streams should start emitting custom combined values after both + * have produced at least one value. + * + * **Gotchas** + * * Note: tracking the latest value is done on a per-array basis. That means * that emitted elements that are not the last value in arrays will never be * used for zipping. * - * @example + * **Example** (Zipping latest values with a function) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4711,18 +5141,23 @@ export declare const zipLatestWith: { * }) * ``` * + * @category zipping * @since 2.0.0 - * @category Zipping */ (left: Stream, right: Stream, f: (left: AL, right: AR) => A): Stream; }; /** - * Races multiple streams and emits values from the first stream to produce a value, interrupting the rest. + * Runs all streams concurrently until one stream emits its first value, then + * mirrors that winning stream and interrupts the rest. * - * @since 3.7.0 - * @category Racing + * **Details** + * + * Failures or completion from losing streams before a winner is chosen are + * ignored unless every stream fails or completes before emitting. After a + * winner is chosen, that stream's later failures are propagated. + * + * **Example** (Racing multiple streams) * - * @example * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -4737,13 +5172,23 @@ export declare const zipLatestWith: { * Effect.runPromise(program) * // Output: [ 0, 1, 2 ] * ``` + * + * @category racing + * @since 3.5.0 */ export declare const raceAll: >>(...streams: S) => Stream, Error, Services>; /** - * Returns a stream that mirrors the first upstream to emit an item. - * As soon as one stream emits, the other is interrupted and failures propagate. + * Runs both streams concurrently until one stream emits its first value, then + * mirrors that winning stream and interrupts the other. + * + * **Details** + * + * A failure or completion from one side before the other side emits does not + * win the race unless both sides fail or complete before emitting. After a + * winner is chosen, that stream's later failures are propagated. + * + * **Example** (Racing two streams) * - * @example * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -4761,15 +5206,22 @@ export declare const raceAll: >>(. * // Output: [ 0, 1, 2 ] * ``` * + * @category racing * @since 3.7.0 - * @category Racing */ export declare const race: { /** - * Returns a stream that mirrors the first upstream to emit an item. - * As soon as one stream emits, the other is interrupted and failures propagate. + * Runs both streams concurrently until one stream emits its first value, then + * mirrors that winning stream and interrupts the other. + * + * **Details** + * + * A failure or completion from one side before the other side emits does not + * win the race unless both sides fail or complete before emitting. After a + * winner is chosen, that stream's later failures are propagated. + * + * **Example** (Racing two streams) * - * @example * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -4787,15 +5239,22 @@ export declare const race: { * // Output: [ 0, 1, 2 ] * ``` * + * @category racing * @since 3.7.0 - * @category Racing */ (right: Stream): (left: Stream) => Stream; /** - * Returns a stream that mirrors the first upstream to emit an item. - * As soon as one stream emits, the other is interrupted and failures propagate. + * Runs both streams concurrently until one stream emits its first value, then + * mirrors that winning stream and interrupts the other. + * + * **Details** + * + * A failure or completion from one side before the other side emits does not + * win the race unless both sides fail or complete before emitting. After a + * winner is chosen, that stream's later failures are propagated. + * + * **Example** (Racing two streams) * - * @example * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -4813,15 +5272,16 @@ export declare const race: { * // Output: [ 0, 1, 2 ] * ``` * + * @category racing * @since 3.7.0 - * @category Racing */ (left: Stream, right: Stream): Stream; }; /** * Filters a stream to the elements that satisfy a predicate. * - * @example + * **Example** (Filtering stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4837,14 +5297,15 @@ export declare const race: { * // Output: [ 2, 4 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const filter: { /** * Filters a stream to the elements that satisfy a predicate. * - * @example + * **Example** (Filtering stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4860,14 +5321,15 @@ export declare const filter: { * // Output: [ 2, 4 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (refinement: Refinement, B>): (self: Stream) => Stream; /** * Filters a stream to the elements that satisfy a predicate. * - * @example + * **Example** (Filtering stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4883,14 +5345,15 @@ export declare const filter: { * // Output: [ 2, 4 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (predicate: Predicate>): (self: Stream) => Stream; /** * Filters a stream to the elements that satisfy a predicate. * - * @example + * **Example** (Filtering stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4906,14 +5369,15 @@ export declare const filter: { * // Output: [ 2, 4 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, refinement: Refinement): Stream; /** * Filters a stream to the elements that satisfy a predicate. * - * @example + * **Example** (Filtering stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4929,37 +5393,77 @@ export declare const filter: { * // Output: [ 2, 4 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, predicate: Predicate): Stream; }; /** * Filters and maps stream elements in one pass using a `Filter`. * - * @since 4.0.0 - * @category Filtering + * **When to use** + * + * Use to keep only stream elements accepted by a `Filter` and emit each filter + * success value. + * + * **Details** + * + * `Result.succeed` values are emitted and `Result.fail` values are skipped. + * + * @see {@link filter} for keeping original elements with a boolean predicate or refinement + * @see {@link filterMapEffect} for an effectful `Filter` + * @see {@link partition} for consuming both filter success and failure values + * + * @category filtering + * @since 2.0.0 */ export declare const filterMap: { /** * Filters and maps stream elements in one pass using a `Filter`. * - * @since 4.0.0 - * @category Filtering + * **When to use** + * + * Use to keep only stream elements accepted by a `Filter` and emit each filter + * success value. + * + * **Details** + * + * `Result.succeed` values are emitted and `Result.fail` values are skipped. + * + * @see {@link filter} for keeping original elements with a boolean predicate or refinement + * @see {@link filterMapEffect} for an effectful `Filter` + * @see {@link partition} for consuming both filter success and failure values + * + * @category filtering + * @since 2.0.0 */ (filter: Filter.Filter, B, X>): (self: Stream) => Stream; /** * Filters and maps stream elements in one pass using a `Filter`. * - * @since 4.0.0 - * @category Filtering + * **When to use** + * + * Use to keep only stream elements accepted by a `Filter` and emit each filter + * success value. + * + * **Details** + * + * `Result.succeed` values are emitted and `Result.fail` values are skipped. + * + * @see {@link filter} for keeping original elements with a boolean predicate or refinement + * @see {@link filterMapEffect} for an effectful `Filter` + * @see {@link partition} for consuming both filter success and failure values + * + * @category filtering + * @since 2.0.0 */ (self: Stream, filter: Filter.Filter): Stream; }; /** - * Effectfully filters elements in a single pass. + * Filters elements in a single pass effectfully. + * + * **Example** (Effectfully filtering stream values) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4974,14 +5478,15 @@ export declare const filterMap: { * // Output: [ 3, 4 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const filterEffect: { /** - * Effectfully filters elements in a single pass. + * Filters elements in a single pass effectfully. + * + * **Example** (Effectfully filtering stream values) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -4996,14 +5501,15 @@ export declare const filterEffect: { * // Output: [ 3, 4 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (predicate: (a: NoInfer, i: number) => Effect.Effect): (self: Stream) => Stream; /** - * Effectfully filters elements in a single pass. + * Filters elements in a single pass effectfully. + * + * **Example** (Effectfully filtering stream values) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5018,39 +5524,87 @@ export declare const filterEffect: { * // Output: [ 3, 4 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, predicate: (a: NoInfer, i: number) => Effect.Effect): Stream; }; /** - * Effectfully filters and maps elements in a single pass. + * Filters and maps elements in one pass effectfully using a `FilterEffect`. * - * @since 4.0.0 - * @category Filtering + * **When to use** + * + * Use to apply effectful logic that can reject stream elements or emit + * transformed values before they continue downstream. + * + * **Details** + * + * `Result.succeed` values are emitted, `Result.fail` values are skipped, and + * effect failures fail the stream. + * + * @see {@link filterMap} for the synchronous `Filter` variant + * @see {@link filterEffect} for effectfully keeping original elements + * @see {@link mapEffect} for effectfully transforming every element + * + * @category filtering + * @since 2.0.0 */ export declare const filterMapEffect: { /** - * Effectfully filters and maps elements in a single pass. + * Filters and maps elements in one pass effectfully using a `FilterEffect`. * - * @since 4.0.0 - * @category Filtering + * **When to use** + * + * Use to apply effectful logic that can reject stream elements or emit + * transformed values before they continue downstream. + * + * **Details** + * + * `Result.succeed` values are emitted, `Result.fail` values are skipped, and + * effect failures fail the stream. + * + * @see {@link filterMap} for the synchronous `Filter` variant + * @see {@link filterEffect} for effectfully keeping original elements + * @see {@link mapEffect} for effectfully transforming every element + * + * @category filtering + * @since 2.0.0 */ (filter: Filter.FilterEffect, B, X, EX, RX>): (self: Stream) => Stream; /** - * Effectfully filters and maps elements in a single pass. + * Filters and maps elements in one pass effectfully using a `FilterEffect`. * - * @since 4.0.0 - * @category Filtering + * **When to use** + * + * Use to apply effectful logic that can reject stream elements or emit + * transformed values before they continue downstream. + * + * **Details** + * + * `Result.succeed` values are emitted, `Result.fail` values are skipped, and + * effect failures fail the stream. + * + * @see {@link filterMap} for the synchronous `Filter` variant + * @see {@link filterEffect} for effectfully keeping original elements + * @see {@link mapEffect} for effectfully transforming every element + * + * @category filtering + * @since 2.0.0 */ (self: Stream, filter: Filter.FilterEffect): Stream; }; /** - * Partitions a stream using a `Filter` and exposes passing and failing values as queues. + * Partitions a stream using a `Filter` and exposes passing and failing values + * as scoped queues. * - * Each queue fails with the stream error or `Cause.Done` when the source ends. + * **Details** + * + * The queues are backed by a fiber in the current scope and should be consumed + * while that scope remains open. Each queue fails with the stream error or + * `Cause.Done` when the source ends. + * + * **Example** (Partitioning a stream into queues) * - * @example * ```ts * import { Console, Effect, Result, Stream } from "effect" * @@ -5071,16 +5625,22 @@ export declare const filterMapEffect: { * Effect.runPromise(Effect.scoped(program)) * ``` * + * @category filtering * @since 4.0.0 - * @category Filtering */ export declare const partitionQueue: { /** - * Partitions a stream using a `Filter` and exposes passing and failing values as queues. + * Partitions a stream using a `Filter` and exposes passing and failing values + * as scoped queues. + * + * **Details** + * + * The queues are backed by a fiber in the current scope and should be consumed + * while that scope remains open. Each queue fails with the stream error or + * `Cause.Done` when the source ends. * - * Each queue fails with the stream error or `Cause.Done` when the source ends. + * **Example** (Partitioning a stream into queues) * - * @example * ```ts * import { Console, Effect, Result, Stream } from "effect" * @@ -5101,8 +5661,8 @@ export declare const partitionQueue: { * Effect.runPromise(Effect.scoped(program)) * ``` * + * @category filtering * @since 4.0.0 - * @category Filtering */ (filter: Filter.Filter, Pass, Fail>, options?: { readonly capacity?: number | "unbounded" | undefined; @@ -5111,11 +5671,17 @@ export declare const partitionQueue: { fails: Queue.Dequeue ], never, R | Scope.Scope>; /** - * Partitions a stream using a `Filter` and exposes passing and failing values as queues. + * Partitions a stream using a `Filter` and exposes passing and failing values + * as scoped queues. * - * Each queue fails with the stream error or `Cause.Done` when the source ends. + * **Details** + * + * The queues are backed by a fiber in the current scope and should be consumed + * while that scope remains open. Each queue fails with the stream error or + * `Cause.Done` when the source ends. + * + * **Example** (Partitioning a stream into queues) * - * @example * ```ts * import { Console, Effect, Result, Stream } from "effect" * @@ -5136,8 +5702,8 @@ export declare const partitionQueue: { * Effect.runPromise(Effect.scoped(program)) * ``` * + * @category filtering * @since 4.0.0 - * @category Filtering */ (self: Stream, filter: Filter.Filter, Pass, Fail>, options?: { readonly capacity?: number | "unbounded" | undefined; @@ -5147,17 +5713,49 @@ export declare const partitionQueue: { ], never, R | Scope.Scope>; }; /** - * Splits a stream using an effectful `Filter`, producing pass and fail streams. + * Splits a stream with an effectful `Filter`, returning scoped streams for + * filter successes and failures. * - * @since 4.0.0 - * @category Filtering - */ + * **When to use** + * + * Use when you need to classify each stream element with an effectful `Filter` + * and consume both passing and failing mapped values as streams. + * + * **Details** + * + * The returned streams are backed by queues in the current scope and should be + * consumed while that scope remains open. The first stream emits success values + * from the filter, and the second emits failure values. + * + * @see {@link partition} for the pure `Filter` variant, which returns the failing stream before the passing stream + * @see {@link partitionQueue} for the lower-level queue result + * @see {@link filterMapEffect} for effectful filtering that discards failed filter results + * + * @category filtering + * @since 4.0.0 + */ export declare const partitionEffect: { /** - * Splits a stream using an effectful `Filter`, producing pass and fail streams. + * Splits a stream with an effectful `Filter`, returning scoped streams for + * filter successes and failures. + * + * **When to use** * + * Use when you need to classify each stream element with an effectful `Filter` + * and consume both passing and failing mapped values as streams. + * + * **Details** + * + * The returned streams are backed by queues in the current scope and should be + * consumed while that scope remains open. The first stream emits success values + * from the filter, and the second emits failure values. + * + * @see {@link partition} for the pure `Filter` variant, which returns the failing stream before the passing stream + * @see {@link partitionQueue} for the lower-level queue result + * @see {@link filterMapEffect} for effectful filtering that discards failed filter results + * + * @category filtering * @since 4.0.0 - * @category Filtering */ (filter: Filter.FilterEffect, Pass, Fail, EX, RX>, options?: { readonly capacity?: number | "unbounded" | undefined; @@ -5167,10 +5765,26 @@ export declare const partitionEffect: { fails: Stream ], never, R | RX | Scope.Scope>; /** - * Splits a stream using an effectful `Filter`, producing pass and fail streams. + * Splits a stream with an effectful `Filter`, returning scoped streams for + * filter successes and failures. + * + * **When to use** + * + * Use when you need to classify each stream element with an effectful `Filter` + * and consume both passing and failing mapped values as streams. + * + * **Details** + * + * The returned streams are backed by queues in the current scope and should be + * consumed while that scope remains open. The first stream emits success values + * from the filter, and the second emits failure values. * + * @see {@link partition} for the pure `Filter` variant, which returns the failing stream before the passing stream + * @see {@link partitionQueue} for the lower-level queue result + * @see {@link filterMapEffect} for effectful filtering that discards failed filter results + * + * @category filtering * @since 4.0.0 - * @category Filtering */ (self: Stream, filter: Filter.FilterEffect, Pass, Fail, EX, RX>, options?: { readonly capacity?: number | "unbounded" | undefined; @@ -5181,15 +5795,17 @@ export declare const partitionEffect: { ], never, R | RX | Scope.Scope>; }; /** - * Splits a stream into excluded and satisfying substreams using a `Filter`. + * Splits a stream into scoped excluded and satisfying substreams using a + * `Filter`. * - * The faster stream may advance up to `bufferSize` elements ahead of the slower - * one. + * **Details** * - * @since 4.0.0 - * @category Filtering + * The returned streams are backed by queues in the current scope and should be + * consumed while that scope remains open. The faster stream may advance up to + * `bufferSize` elements ahead of the slower one. + * + * **Example** (Partitioning a stream) * - * @example * ```ts * import { Console, Effect, Result, Stream } from "effect" * @@ -5206,18 +5822,23 @@ export declare const partitionEffect: { * // Output: [ 2, 4 ] * }) * ``` + * + * @category filtering + * @since 2.0.0 */ export declare const partition: { /** - * Splits a stream into excluded and satisfying substreams using a `Filter`. + * Splits a stream into scoped excluded and satisfying substreams using a + * `Filter`. * - * The faster stream may advance up to `bufferSize` elements ahead of the slower - * one. + * **Details** * - * @since 4.0.0 - * @category Filtering + * The returned streams are backed by queues in the current scope and should be + * consumed while that scope remains open. The faster stream may advance up to + * `bufferSize` elements ahead of the slower one. + * + * **Example** (Partitioning a stream) * - * @example * ```ts * import { Console, Effect, Result, Stream } from "effect" * @@ -5234,6 +5855,9 @@ export declare const partition: { * // Output: [ 2, 4 ] * }) * ``` + * + * @category filtering + * @since 2.0.0 */ (filter: Filter.Filter, Pass, Fail>, options?: { readonly bufferSize?: number | undefined; @@ -5242,15 +5866,17 @@ export declare const partition: { satisfying: Stream ], never, R | Scope.Scope>; /** - * Splits a stream into excluded and satisfying substreams using a `Filter`. + * Splits a stream into scoped excluded and satisfying substreams using a + * `Filter`. * - * The faster stream may advance up to `bufferSize` elements ahead of the slower - * one. + * **Details** * - * @since 4.0.0 - * @category Filtering + * The returned streams are backed by queues in the current scope and should be + * consumed while that scope remains open. The faster stream may advance up to + * `bufferSize` elements ahead of the slower one. + * + * **Example** (Partitioning a stream) * - * @example * ```ts * import { Console, Effect, Result, Stream } from "effect" * @@ -5267,6 +5893,9 @@ export declare const partition: { * // Output: [ 2, 4 ] * }) * ``` + * + * @category filtering + * @since 2.0.0 */ (self: Stream, filter: Filter.Filter, Pass, Fail>, options?: { readonly bufferSize?: number | undefined; @@ -5279,7 +5908,8 @@ export declare const partition: { * Returns the specified stream if the given condition is satisfied, otherwise * returns an empty stream. * - * @example + * **Example** (Conditionally keeping a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5294,15 +5924,16 @@ export declare const partition: { * // Output: [] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const when: { /** * Returns the specified stream if the given condition is satisfied, otherwise * returns an empty stream. * - * @example + * **Example** (Conditionally keeping a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5317,15 +5948,16 @@ export declare const when: { * // Output: [] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (test: Effect.Effect): (self: Stream) => Stream; /** * Returns the specified stream if the given condition is satisfied, otherwise * returns an empty stream. * - * @example + * **Example** (Conditionally keeping a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5340,8 +5972,8 @@ export declare const when: { * // Output: [] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, test: Effect.Effect): Stream; }; @@ -5349,9 +5981,12 @@ export declare const when: { * Runs a sink to peel off enough elements to produce a value and returns that * value with the remaining stream in a scope. * + * **Details** + * * The returned stream is only valid within the scope. * - * @example + * **Example** (Peeling a stream with a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -5370,17 +6005,20 @@ export declare const when: { * // Output: [ [1, 2, 3], [4, 5, 6] ] * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const peel: { /** * Runs a sink to peel off enough elements to produce a value and returns that * value with the remaining stream in a scope. * + * **Details** + * * The returned stream is only valid within the scope. * - * @example + * **Example** (Peeling a stream with a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -5399,17 +6037,20 @@ export declare const peel: { * // Output: [ [1, 2, 3], [4, 5, 6] ] * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (sink: Sink.Sink): (self: Stream) => Effect.Effect<[A2, Stream], E2 | E, Scope.Scope | R2 | R>; /** * Runs a sink to peel off enough elements to produce a value and returns that * value with the remaining stream in a scope. * + * **Details** + * * The returned stream is only valid within the scope. * - * @example + * **Example** (Peeling a stream with a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -5428,8 +6069,8 @@ export declare const peel: { * // Output: [ [1, 2, 3], [4, 5, 6] ] * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, sink: Sink.Sink): Effect.Effect<[A2, Stream], E | E2, Scope.Scope | R | R2>; }; @@ -5437,10 +6078,15 @@ export declare const peel: { * Buffers up to `capacity` elements so a faster producer can progress * independently of a slower consumer. * - * Note: This combinator destroys chunking. Use `Stream.rechunk` afterwards if - * you need fixed chunk sizes. + * **Details** + * + * Finite buffers use the configured queue strategy: `"suspend"` applies + * backpressure, while `"dropping"` and `"sliding"` may discard elements when + * the buffer is full. This combinator destroys chunking; use `Stream.rechunk` + * afterward if you need fixed chunk sizes. + * + * **Example** (Buffering stream elements) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5456,18 +6102,23 @@ export declare const peel: { * // Output: [ 1, 2, 3 ] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ export declare const buffer: { /** * Buffers up to `capacity` elements so a faster producer can progress * independently of a slower consumer. * - * Note: This combinator destroys chunking. Use `Stream.rechunk` afterwards if - * you need fixed chunk sizes. + * **Details** + * + * Finite buffers use the configured queue strategy: `"suspend"` applies + * backpressure, while `"dropping"` and `"sliding"` may discard elements when + * the buffer is full. This combinator destroys chunking; use `Stream.rechunk` + * afterward if you need fixed chunk sizes. + * + * **Example** (Buffering stream elements) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5483,8 +6134,8 @@ export declare const buffer: { * // Output: [ 1, 2, 3 ] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (options: { readonly capacity: "unbounded"; @@ -5496,10 +6147,15 @@ export declare const buffer: { * Buffers up to `capacity` elements so a faster producer can progress * independently of a slower consumer. * - * Note: This combinator destroys chunking. Use `Stream.rechunk` afterwards if - * you need fixed chunk sizes. + * **Details** + * + * Finite buffers use the configured queue strategy: `"suspend"` applies + * backpressure, while `"dropping"` and `"sliding"` may discard elements when + * the buffer is full. This combinator destroys chunking; use `Stream.rechunk` + * afterward if you need fixed chunk sizes. + * + * **Example** (Buffering stream elements) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5515,8 +6171,8 @@ export declare const buffer: { * // Output: [ 1, 2, 3 ] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (self: Stream, options: { readonly capacity: "unbounded"; @@ -5529,15 +6185,15 @@ export declare const buffer: { * Allows a faster producer to progress independently of a slower consumer by * buffering up to `capacity` chunks in a queue. * - * This combinator preserves chunking and is best with power-of-2 capacities. + * **Details** * - * **Previously Known As** + * Finite buffers use the configured queue strategy: `"suspend"` applies + * backpressure, while `"dropping"` and `"sliding"` may discard chunks when the + * buffer is full. This combinator preserves chunking and is best with + * power-of-2 capacities. * - * This API replaces the following from Effect 3.x: + * **Example** (Buffering stream chunks) * - * - `Stream.bufferChunks` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5552,23 +6208,23 @@ export declare const buffer: { * // Output: [ 1, 2, 3, 4 ] * ``` * - * @since 2.0.0 - * @category Rate Limiting + * @category rate limiting + * @since 4.0.0 */ export declare const bufferArray: { /** * Allows a faster producer to progress independently of a slower consumer by * buffering up to `capacity` chunks in a queue. * - * This combinator preserves chunking and is best with power-of-2 capacities. - * - * **Previously Known As** + * **Details** * - * This API replaces the following from Effect 3.x: + * Finite buffers use the configured queue strategy: `"suspend"` applies + * backpressure, while `"dropping"` and `"sliding"` may discard chunks when the + * buffer is full. This combinator preserves chunking and is best with + * power-of-2 capacities. * - * - `Stream.bufferChunks` + * **Example** (Buffering stream chunks) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5583,8 +6239,8 @@ export declare const bufferArray: { * // Output: [ 1, 2, 3, 4 ] * ``` * - * @since 2.0.0 - * @category Rate Limiting + * @category rate limiting + * @since 4.0.0 */ (options: { readonly capacity: "unbounded"; @@ -5596,15 +6252,15 @@ export declare const bufferArray: { * Allows a faster producer to progress independently of a slower consumer by * buffering up to `capacity` chunks in a queue. * - * This combinator preserves chunking and is best with power-of-2 capacities. + * **Details** * - * **Previously Known As** + * Finite buffers use the configured queue strategy: `"suspend"` applies + * backpressure, while `"dropping"` and `"sliding"` may discard chunks when the + * buffer is full. This combinator preserves chunking and is best with + * power-of-2 capacities. * - * This API replaces the following from Effect 3.x: + * **Example** (Buffering stream chunks) * - * - `Stream.bufferChunks` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5619,8 +6275,8 @@ export declare const bufferArray: { * // Output: [ 1, 2, 3, 4 ] * ``` * - * @since 2.0.0 - * @category Rate Limiting + * @category rate limiting + * @since 4.0.0 */ (self: Stream, options: { readonly capacity: "unbounded"; @@ -5634,13 +6290,8 @@ export declare const bufferArray: { * one fails. Allows recovery from all causes of failure, including * interruption if the stream is uninterruptible. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Catching stream causes) * - * - `Stream.catchAllCause` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5662,8 +6313,8 @@ export declare const bufferArray: { * // Output: [ 1, 2, 999 ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ export declare const catchCause: { /** @@ -5671,13 +6322,8 @@ export declare const catchCause: { * one fails. Allows recovery from all causes of failure, including * interruption if the stream is uninterruptible. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Catching stream causes) * - * - `Stream.catchAllCause` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5699,8 +6345,8 @@ export declare const catchCause: { * // Output: [ 1, 2, 999 ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ (f: (cause: Cause.Cause) => Stream): (self: Stream) => Stream; /** @@ -5708,13 +6354,8 @@ export declare const catchCause: { * one fails. Allows recovery from all causes of failure, including * interruption if the stream is uninterruptible. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Catching stream causes) * - * - `Stream.catchAllCause` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5736,8 +6377,8 @@ export declare const catchCause: { * // Output: [ 1, 2, 999 ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ (self: Stream, f: (cause: Cause.Cause) => Stream): Stream; }; @@ -5745,13 +6386,8 @@ export declare const catchCause: { * Runs an effect when the stream fails without changing its values or error, * unless the tap effect itself fails. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Tapping stream causes) * - * - `Stream.tapErrorCause` - * - * @example * ```ts * import { Cause, Console, Effect, Stream } from "effect" * @@ -5771,21 +6407,16 @@ export declare const catchCause: { * // Output: [ 1, 2, 0 ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ export declare const tapCause: { /** * Runs an effect when the stream fails without changing its values or error, * unless the tap effect itself fails. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Tapping stream causes) * - * - `Stream.tapErrorCause` - * - * @example * ```ts * import { Cause, Console, Effect, Stream } from "effect" * @@ -5805,21 +6436,16 @@ export declare const tapCause: { * // Output: [ 1, 2, 0 ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ (f: (cause: Cause.Cause) => Effect.Effect): (self: Stream) => Stream; /** * Runs an effect when the stream fails without changing its values or error, * unless the tap effect itself fails. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Tapping stream causes) * - * - `Stream.tapErrorCause` - * - * @example * ```ts * import { Cause, Console, Effect, Stream } from "effect" * @@ -5839,8 +6465,8 @@ export declare const tapCause: { * // Output: [ 1, 2, 0 ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ (self: Stream, f: (cause: Cause.Cause) => Effect.Effect): Stream; }; @@ -5852,13 +6478,8 @@ export { /** * Switches over to the stream produced by the provided function if this one fails. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Catching stream failures) * - * - `Stream.catchAll` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5876,14 +6497,15 @@ export { * // Output: [ 1, 2, 999 ] * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ catch_ as catch }; /** - * Effectfully peeks at errors without changing the stream unless the tap fails. + * Peeks at errors effectfully without changing the stream unless the tap fails. + * + * **Example** (Effectfully peeking at errors) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5904,14 +6526,15 @@ catch_ as catch }; * // [ 1, 2, 999 ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ export declare const tapError: { /** - * Effectfully peeks at errors without changing the stream unless the tap fails. + * Peeks at errors effectfully without changing the stream unless the tap fails. + * + * **Example** (Effectfully peeking at errors) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5932,14 +6555,15 @@ export declare const tapError: { * // [ 1, 2, 999 ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ (f: (error: E) => Effect.Effect): (self: Stream) => Stream; /** - * Effectfully peeks at errors without changing the stream unless the tap fails. + * Peeks at errors effectfully without changing the stream unless the tap fails. + * + * **Example** (Effectfully peeking at errors) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5960,25 +6584,22 @@ export declare const tapError: { * // [ 1, 2, 999 ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ (self: Stream, f: (error: E) => Effect.Effect): Stream; }; /** * Recovers from errors that match a predicate by switching to a recovery stream. * + * **Details** + * * When a failure matches the filter, the stream switches to the recovery * stream. Non-matching failures propagate downstream, so the error type is * preserved unless the filter narrows it. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Catching matching failures) * - * - `Stream.catchSome` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -5999,24 +6620,21 @@ export declare const tapError: { * Effect.runPromise(program) * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ export declare const catchIf: { /** * Recovers from errors that match a predicate by switching to a recovery stream. * + * **Details** + * * When a failure matches the filter, the stream switches to the recovery * stream. Non-matching failures propagate downstream, so the error type is * preserved unless the filter narrows it. * - * **Previously Known As** + * **Example** (Catching matching failures) * - * This API replaces the following from Effect 3.x: - * - * - `Stream.catchSome` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6037,24 +6655,21 @@ export declare const catchIf: { * Effect.runPromise(program) * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ - , R3 = never>(refinement: Refinement, EB>, f: (e: EB) => Stream, orElse?: ((e: Exclude) => Stream) | undefined): (self: Stream) => Stream; + (refinement: Refinement, EB>, f: (e: EB) => Stream, orElse?: ((e: Exclude) => Stream) | undefined): (self: Stream) => Stream, E2 | E3 | (A3 extends unassigned ? Exclude : never), R | R2 | R3>; /** * Recovers from errors that match a predicate by switching to a recovery stream. * + * **Details** + * * When a failure matches the filter, the stream switches to the recovery * stream. Non-matching failures propagate downstream, so the error type is * preserved unless the filter narrows it. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Catching matching failures) * - * - `Stream.catchSome` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6075,24 +6690,21 @@ export declare const catchIf: { * Effect.runPromise(program) * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ - (predicate: Predicate>, f: (e: NoInfer) => Stream, orElse?: ((e: NoInfer) => Stream) | undefined): (self: Stream) => Stream; + (predicate: Predicate>, f: (e: NoInfer) => Stream, orElse?: ((e: NoInfer) => Stream) | undefined): (self: Stream) => Stream, E2 | E3 | (A3 extends unassigned ? E : never), R | R2 | R3>; /** * Recovers from errors that match a predicate by switching to a recovery stream. * + * **Details** + * * When a failure matches the filter, the stream switches to the recovery * stream. Non-matching failures propagate downstream, so the error type is * preserved unless the filter narrows it. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: - * - * - `Stream.catchSome` + * **Example** (Catching matching failures) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6113,24 +6725,21 @@ export declare const catchIf: { * Effect.runPromise(program) * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ - , R3 = never>(self: Stream, refinement: Refinement, f: (e: EB) => Stream, orElse?: ((e: Exclude) => Stream) | undefined): Stream; + (self: Stream, refinement: Refinement, f: (e: EB) => Stream, orElse?: ((e: Exclude) => Stream) | undefined): Stream, E2 | E3 | (A3 extends unassigned ? Exclude : never), R | R2 | R3>; /** * Recovers from errors that match a predicate by switching to a recovery stream. * + * **Details** + * * When a failure matches the filter, the stream switches to the recovery * stream. Non-matching failures propagate downstream, so the error type is * preserved unless the filter narrows it. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: + * **Example** (Catching matching failures) * - * - `Stream.catchSome` - * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6151,46 +6760,92 @@ export declare const catchIf: { * Effect.runPromise(program) * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ - (self: Stream, predicate: Predicate, f: (e: E) => Stream, orElse?: ((e: E) => Stream) | undefined): Stream; + (self: Stream, predicate: Predicate, f: (e: E) => Stream, orElse?: ((e: E) => Stream) | undefined): Stream, E2 | E3 | (A3 extends unassigned ? E : never), R | R2 | R3>; }; /** * Recovers from errors that match a `Filter` by switching to a recovery * stream. * + * **When to use** + * + * Use to recover from stream errors with a reusable `Filter` when matching can + * also narrow or transform the error before choosing the recovery stream. + * + * **Details** + * + * Successful filter results are passed to `f`. Failed filter results go to + * `orElse` when provided; otherwise the filter failure is re-failed. + * + * @see {@link catchIf} for predicate or refinement based recovery + * @see {@link catchTag} for `_tag` based recovery from one tagged error + * @see {@link catchTags} for `_tag` based recovery from multiple tagged errors + * @see {@link catchCauseFilter} for filtering full causes + * + * @category error handling * @since 4.0.0 - * @category Error Handling */ export declare const catchFilter: { /** * Recovers from errors that match a `Filter` by switching to a recovery * stream. * + * **When to use** + * + * Use to recover from stream errors with a reusable `Filter` when matching can + * also narrow or transform the error before choosing the recovery stream. + * + * **Details** + * + * Successful filter results are passed to `f`. Failed filter results go to + * `orElse` when provided; otherwise the filter failure is re-failed. + * + * @see {@link catchIf} for predicate or refinement based recovery + * @see {@link catchTag} for `_tag` based recovery from one tagged error + * @see {@link catchTags} for `_tag` based recovery from multiple tagged errors + * @see {@link catchCauseFilter} for filtering full causes + * + * @category error handling * @since 4.0.0 - * @category Error Handling */ - (filter: Filter.Filter, EB, X>, f: (failure: EB) => Stream, orElse?: ((failure: X) => Stream) | undefined): (self: Stream) => Stream; + (filter: Filter.Filter, EB, X>, f: (failure: EB) => Stream, orElse?: ((failure: X) => Stream) | undefined): (self: Stream) => Stream, E2 | E3 | (A3 extends unassigned ? X : never), R | R2 | R3>; /** * Recovers from errors that match a `Filter` by switching to a recovery * stream. * + * **When to use** + * + * Use to recover from stream errors with a reusable `Filter` when matching can + * also narrow or transform the error before choosing the recovery stream. + * + * **Details** + * + * Successful filter results are passed to `f`. Failed filter results go to + * `orElse` when provided; otherwise the filter failure is re-failed. + * + * @see {@link catchIf} for predicate or refinement based recovery + * @see {@link catchTag} for `_tag` based recovery from one tagged error + * @see {@link catchTags} for `_tag` based recovery from multiple tagged errors + * @see {@link catchCauseFilter} for filtering full causes + * + * @category error handling * @since 4.0.0 - * @category Error Handling */ - (self: Stream, filter: Filter.Filter, EB, X>, f: (failure: EB) => Stream, orElse?: ((failure: X) => Stream) | undefined): Stream; + (self: Stream, filter: Filter.Filter, EB, X>, f: (failure: EB) => Stream, orElse?: ((failure: X) => Stream) | undefined): Stream, E2 | E3 | (A3 extends unassigned ? X : never), R | R2 | R3>; }; /** * Recovers from failures whose `_tag` matches the provided value by switching to * the stream returned by `f`. * - * **When to Use** + * **When to use** * - * Use `catchTag` when your error type is a tagged union with a readonly `_tag` - * field and you want to handle a specific error case. + * Use when you need to handle a specific error case from a stream whose error + * type is a tagged union with a readonly `_tag` field. + * + * **Example** (Catching tagged failures) * - * @example * ```ts * import { Console, Data, Effect, Stream } from "effect" * @@ -6211,20 +6866,21 @@ export declare const catchFilter: { * Effect.runPromise(program) * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ export declare const catchTag: { /** * Recovers from failures whose `_tag` matches the provided value by switching to * the stream returned by `f`. * - * **When to Use** + * **When to use** + * + * Use when you need to handle a specific error case from a stream whose error + * type is a tagged union with a readonly `_tag` field. * - * Use `catchTag` when your error type is a tagged union with a readonly `_tag` - * field and you want to handle a specific error case. + * **Example** (Catching tagged failures) * - * @example * ```ts * import { Console, Data, Effect, Stream } from "effect" * @@ -6245,20 +6901,21 @@ export declare const catchTag: { * Effect.runPromise(program) * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ - | Arr.NonEmptyReadonlyArray>, E, A1, E1, R1, A2 = never, E2 = ExcludeTag ? K[number] : K>, R2 = never>(k: K, f: (e: ExtractTag, K extends Arr.NonEmptyReadonlyArray ? K[number] : K>) => Stream, orElse?: ((e: ExcludeTag ? K[number] : K>) => Stream) | undefined): (self: Stream) => Stream; + | Arr.NonEmptyReadonlyArray>, E, A1, E1, R1, A2 = unassigned, E2 = never, R2 = never>(k: K, f: (e: ExtractTag, K extends Arr.NonEmptyReadonlyArray ? K[number] : K>) => Stream, orElse?: ((e: ExcludeTag ? K[number] : K>) => Stream) | undefined): (self: Stream) => Stream, E1 | E2 | (A2 extends unassigned ? ExcludeTag ? K[number] : K> : never), R | R1 | R2>; /** * Recovers from failures whose `_tag` matches the provided value by switching to * the stream returned by `f`. * - * **When to Use** + * **When to use** * - * Use `catchTag` when your error type is a tagged union with a readonly `_tag` - * field and you want to handle a specific error case. + * Use when you need to handle a specific error case from a stream whose error + * type is a tagged union with a readonly `_tag` field. + * + * **Example** (Catching tagged failures) * - * @example * ```ts * import { Console, Data, Effect, Stream } from "effect" * @@ -6279,15 +6936,16 @@ export declare const catchTag: { * Effect.runPromise(program) * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ - | Arr.NonEmptyReadonlyArray>, R1, E1, A1, A2 = never, E2 = ExcludeTag ? K[number] : K>, R2 = never>(self: Stream, k: K, f: (e: ExtractTag ? K[number] : K>) => Stream, orElse?: ((e: ExcludeTag ? K[number] : K>) => Stream) | undefined): Stream; + | Arr.NonEmptyReadonlyArray>, R1, E1, A1, A2 = unassigned, E2 = never, R2 = never>(self: Stream, k: K, f: (e: ExtractTag ? K[number] : K>) => Stream, orElse?: ((e: ExcludeTag ? K[number] : K>) => Stream) | undefined): Stream, E1 | E2 | (A2 extends unassigned ? ExcludeTag ? K[number] : K> : never), R | R1 | R2>; }; /** * Switches to a recovery stream based on matching `_tag` handlers. * - * @example + * **Example** (Catching tagged failures with handlers) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6317,14 +6975,15 @@ export declare const catchTag: { * // Output: [ "fallback" ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ export declare const catchTags: { /** * Switches to a recovery stream based on matching `_tag` handlers. * - * @example + * **Example** (Catching tagged failures with handlers) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6354,8 +7013,8 @@ export declare const catchTags: { * // Output: [ "fallback" ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ ) => Stream; - } : {}), A2 = never, E2 = Exclude, R2 = never>(cases: Cases, orElse?: ((e: Exclude(cases: Cases, orElse?: ((e: Exclude) => Stream) | undefined): (self: Stream) => Stream) => Stream) | undefined): (self: Stream) => Stream | { [K in keyof Cases]: Cases[K] extends ((...args: Array) => Stream) ? A : never; - }[keyof Cases], E2 | { + }[keyof Cases], E2 | (A2 extends unassigned ? Exclude : never) | { [K in keyof Cases]: Cases[K] extends ((...args: Array) => Stream) ? E : never; }[keyof Cases], R | R2 | { [K in keyof Cases]: Cases[K] extends ((...args: Array) => Stream) ? R : never; @@ -6377,7 +7036,8 @@ export declare const catchTags: { /** * Switches to a recovery stream based on matching `_tag` handlers. * - * @example + * **Example** (Catching tagged failures with handlers) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6407,8 +7067,8 @@ export declare const catchTags: { * // Output: [ "fallback" ] * ``` * - * @since 4.0.0 - * @category Error Handling + * @category error handling + * @since 2.0.0 */ ) => Stream; - } : {}), A2 = never, E2 = Exclude(self: Stream, cases: Cases, orElse?: ((e: Exclude, R2 = never>(self: Stream, cases: Cases, orElse?: ((e: Exclude) => Stream) | undefined): Stream) => Stream) | undefined): Stream | { [K in keyof Cases]: Cases[K] extends ((...args: Array) => Stream) ? A : never; - }[keyof Cases], E2 | { + }[keyof Cases], E2 | (A2 extends unassigned ? Exclude : never) | { [K in keyof Cases]: Cases[K] extends ((...args: Array) => Stream) ? E : never; }[keyof Cases], R | R2 | { [K in keyof Cases]: Cases[K] extends ((...args: Array) => Stream) ? R : never; @@ -6431,10 +7091,17 @@ export declare const catchTags: { /** * Catches a specific reason within a tagged error. * - * Use this to handle nested error causes without removing the parent error - * from the error channel. The handler receives the unwrapped reason. + * **When to use** + * + * Use to handle nested error causes without removing the parent error + * from the error channel. + * + * **Details** + * + * The handler receives the unwrapped reason. + * + * **Example** (Catching a tagged error reason) * - * @example * ```ts * import { Console, Data, Effect, Stream } from "effect" * @@ -6468,17 +7135,24 @@ export declare const catchTags: { * // Output: [ "retry: 60" ] * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ export declare const catchReason: { /** * Catches a specific reason within a tagged error. * - * Use this to handle nested error causes without removing the parent error - * from the error channel. The handler receives the unwrapped reason. + * **When to use** + * + * Use to handle nested error causes without removing the parent error + * from the error channel. + * + * **Details** + * + * The handler receives the unwrapped reason. + * + * **Example** (Catching a tagged error reason) * - * @example * ```ts * import { Console, Data, Effect, Stream } from "effect" * @@ -6512,17 +7186,24 @@ export declare const catchReason: { * // Output: [ "retry: 60" ] * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ - , E, RK extends ReasonTags, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(errorTag: K, reasonTag: RK, f: (reason: ExtractReason, K>, RK>, error: NarrowReason, K>, RK>) => Stream, orElse?: ((reason: ExcludeReason, K>, RK>, error: OmitReason, K>, RK>) => Stream) | undefined): (self: Stream) => Stream, (A3 extends unassigned ? E : ExcludeTag) | E2 | E3, R | R2 | R3>; + , E, RK extends ReasonTags, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(errorTag: K, reasonTag: RK, f: (reason: ExtractReason, K>, RK>, error: NarrowReason, K>, RK>) => Stream, orElse?: ((reason: ExcludeReason, K>, RK>, error: OmitReason, K>, RK>) => Stream) | undefined): (self: Stream) => Stream, ExcludeTag | E2 | E3 | (A3 extends unassigned ? ExtractTag : never), R | R2 | R3>; /** * Catches a specific reason within a tagged error. * - * Use this to handle nested error causes without removing the parent error - * from the error channel. The handler receives the unwrapped reason. + * **When to use** + * + * Use to handle nested error causes without removing the parent error + * from the error channel. + * + * **Details** + * + * The handler receives the unwrapped reason. + * + * **Example** (Catching a tagged error reason) * - * @example * ```ts * import { Console, Data, Effect, Stream } from "effect" * @@ -6556,15 +7237,16 @@ export declare const catchReason: { * // Output: [ "retry: 60" ] * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ - , RK extends ReasonTags>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(self: Stream, errorTag: K, reasonTag: RK, f: (reason: ExtractReason, RK>, error: NarrowReason, RK>) => Stream, orElse?: ((reason: ExcludeReason, RK>, error: OmitReason, RK>) => Stream) | undefined): Stream, (A3 extends unassigned ? E : ExcludeTag) | E2 | E3, R | R2 | R3>; + , RK extends ReasonTags>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(self: Stream, errorTag: K, reasonTag: RK, f: (reason: ExtractReason, RK>, error: NarrowReason, RK>) => Stream, orElse?: ((reason: ExcludeReason, RK>, error: OmitReason, RK>) => Stream) | undefined): Stream, ExcludeTag | E2 | E3 | (A3 extends unassigned ? ExtractTag : never), R | R2 | R3>; }; /** * Catches multiple reasons within a tagged error using an object of handlers. * - * @example + * **Example** (Catching tagged error reasons) + * * ```ts * import { Console, Data, Effect, Stream } from "effect" * @@ -6599,14 +7281,15 @@ export declare const catchReason: { * // Output: [ "retry: 60" ] * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ export declare const catchReasons: { /** * Catches multiple reasons within a tagged error using an object of handlers. * - * @example + * **Example** (Catching tagged error reasons) + * * ```ts * import { Console, Data, Effect, Stream } from "effect" * @@ -6641,14 +7324,14 @@ export declare const catchReasons: { * // Output: [ "retry: 60" ] * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ , E, Cases extends { [RK in ReasonTags, K>>]+?: (reason: ExtractReason, K>, RK>, error: NarrowReason, K>, RK>) => Stream; }, A2 = unassigned, E2 = never, R2 = never>(errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason, K>, Extract>, error: OmitReason, K>, Extract>) => Stream) | undefined): (self: Stream) => Stream | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Stream ? A : never; - }[keyof Cases], (A2 extends unassigned ? E : ExcludeTag) | E2 | { + }[keyof Cases], ExcludeTag | E2 | (A2 extends unassigned ? ExtractTag : never) | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Stream ? E : never; }[keyof Cases], R | R2 | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Stream ? R : never; @@ -6656,7 +7339,8 @@ export declare const catchReasons: { /** * Catches multiple reasons within a tagged error using an object of handlers. * - * @example + * **Example** (Catching tagged error reasons) + * * ```ts * import { Console, Data, Effect, Stream } from "effect" * @@ -6691,14 +7375,14 @@ export declare const catchReasons: { * // Output: [ "retry: 60" ] * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ , Cases extends { [RK in ReasonTags>]+?: (reason: ExtractReason, RK>, error: NarrowReason, RK>) => Stream; }, A2 = unassigned, E2 = never, R2 = never>(self: Stream, errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason, K>, Extract>, error: OmitReason, K>, Extract>) => Stream) | undefined): Stream | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Stream ? A : never; - }[keyof Cases], (A2 extends unassigned ? E : ExcludeTag) | E2 | { + }[keyof Cases], ExcludeTag | E2 | (A2 extends unassigned ? ExtractTag : never) | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Stream ? E : never; }[keyof Cases], R | R2 | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Stream ? R : never; @@ -6707,7 +7391,8 @@ export declare const catchReasons: { /** * Transforms the errors emitted by this stream using `f`. * - * @example + * **Example** (Mapping stream errors) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6724,14 +7409,15 @@ export declare const catchReasons: { * // Output: [ "recovered from mapped: bad" ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ export declare const mapError: { /** * Transforms the errors emitted by this stream using `f`. * - * @example + * **Example** (Mapping stream errors) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6748,14 +7434,15 @@ export declare const mapError: { * // Output: [ "recovered from mapped: bad" ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ (f: (error: E) => E2): (self: Stream) => Stream; /** * Transforms the errors emitted by this stream using `f`. * - * @example + * **Example** (Mapping stream errors) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6772,8 +7459,8 @@ export declare const mapError: { * // Output: [ "recovered from mapped: bad" ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ (self: Stream, f: (error: E) => E2): Stream; }; @@ -6781,13 +7468,8 @@ export declare const mapError: { * Recovers from stream failures by filtering the `Cause` and switching to a recovery stream. * Non-matching causes are re-emitted as failures. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: - * - * - `Stream.catchSomeCause` + * **Example** (Catching matching causes) * - * @example * ```ts * import { Cause, Console, Effect, Stream } from "effect" * @@ -6807,21 +7489,16 @@ export declare const mapError: { * // Output: [ "Recovered: NetworkError" ] * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ export declare const catchCauseIf: { /** * Recovers from stream failures by filtering the `Cause` and switching to a recovery stream. * Non-matching causes are re-emitted as failures. * - * **Previously Known As** + * **Example** (Catching matching causes) * - * This API replaces the following from Effect 3.x: - * - * - `Stream.catchSomeCause` - * - * @example * ```ts * import { Cause, Console, Effect, Stream } from "effect" * @@ -6841,21 +7518,16 @@ export declare const catchCauseIf: { * // Output: [ "Recovered: NetworkError" ] * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ (predicate: Predicate>, f: (cause: Cause.Cause) => Stream): (self: Stream) => Stream; /** * Recovers from stream failures by filtering the `Cause` and switching to a recovery stream. * Non-matching causes are re-emitted as failures. * - * **Previously Known As** - * - * This API replaces the following from Effect 3.x: - * - * - `Stream.catchSomeCause` + * **Example** (Catching matching causes) * - * @example * ```ts * import { Cause, Console, Effect, Stream } from "effect" * @@ -6875,8 +7547,8 @@ export declare const catchCauseIf: { * // Output: [ "Recovered: NetworkError" ] * ``` * + * @category error handling * @since 4.0.0 - * @category Error Handling */ (self: Stream, predicate: Predicate>, f: (cause: Cause.Cause) => Stream): Stream; }; @@ -6884,31 +7556,80 @@ export declare const catchCauseIf: { * Recovers from stream failures by filtering the `Cause` and switching to a * recovery stream. * + * **When to use** + * + * Use when you need to recover a stream only from causes selected by a + * `Filter`, while giving the recovery both the selected value and the original + * `Cause`. + * + * **Details** + * + * The filter is applied to the full `Cause`. A successful filter result is + * passed to `f` together with the original cause; a failed filter result + * re-fails with the residual cause. + * + * @see {@link catchCauseIf} for predicate-based cause selection + * @see {@link catchFilter} for filtering typed error values instead of full causes + * @see {@link catchCause} for recovering from every cause without filtering + * + * @category error handling * @since 4.0.0 - * @category Error Handling */ export declare const catchCauseFilter: { /** * Recovers from stream failures by filtering the `Cause` and switching to a * recovery stream. * + * **When to use** + * + * Use when you need to recover a stream only from causes selected by a + * `Filter`, while giving the recovery both the selected value and the original + * `Cause`. + * + * **Details** + * + * The filter is applied to the full `Cause`. A successful filter result is + * passed to `f` together with the original cause; a failed filter result + * re-fails with the residual cause. + * + * @see {@link catchCauseIf} for predicate-based cause selection + * @see {@link catchFilter} for filtering typed error values instead of full causes + * @see {@link catchCause} for recovering from every cause without filtering + * + * @category error handling * @since 4.0.0 - * @category Error Handling */ >(filter: Filter.Filter, EB, X>, f: (failure: EB, cause: Cause.Cause) => Stream): (self: Stream) => Stream | E2, R2 | R>; /** * Recovers from stream failures by filtering the `Cause` and switching to a * recovery stream. * + * **When to use** + * + * Use when you need to recover a stream only from causes selected by a + * `Filter`, while giving the recovery both the selected value and the original + * `Cause`. + * + * **Details** + * + * The filter is applied to the full `Cause`. A successful filter result is + * passed to `f` together with the original cause; a failed filter result + * re-fails with the residual cause. + * + * @see {@link catchCauseIf} for predicate-based cause selection + * @see {@link catchFilter} for filtering typed error values instead of full causes + * @see {@link catchCause} for recovering from every cause without filtering + * + * @category error handling * @since 4.0.0 - * @category Error Handling */ >(self: Stream, filter: Filter.Filter, EB, X>, f: (failure: EB, cause: Cause.Cause) => Stream): Stream | E2, R | R2>; }; /** * Switches to a fallback stream if this stream is empty. * - * @example + * **Example** (Switching on empty streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6924,14 +7645,15 @@ export declare const catchCauseFilter: { * // Output: [ 1, 2 ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ export declare const orElseIfEmpty: { /** * Switches to a fallback stream if this stream is empty. * - * @example + * **Example** (Switching on empty streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6947,14 +7669,15 @@ export declare const orElseIfEmpty: { * // Output: [ 1, 2 ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ (orElse: LazyArg>): (self: Stream) => Stream; /** * Switches to a fallback stream if this stream is empty. * - * @example + * **Example** (Switching on empty streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6970,15 +7693,16 @@ export declare const orElseIfEmpty: { * // Output: [ 1, 2 ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ (self: Stream, orElse: LazyArg>): Stream; }; /** * Returns a stream that emits a fallback value when this stream fails. * - * @example + * **Example** (Recovering with a fallback value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -6995,14 +7719,15 @@ export declare const orElseIfEmpty: { * // Output: [ "Recovered: NetworkError" ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ export declare const orElseSucceed: { /** * Returns a stream that emits a fallback value when this stream fails. * - * @example + * **Example** (Recovering with a fallback value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7019,14 +7744,15 @@ export declare const orElseSucceed: { * // Output: [ "Recovered: NetworkError" ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ (f: (error: E) => A2): (self: Stream) => Stream; /** * Returns a stream that emits a fallback value when this stream fails. * - * @example + * **Example** (Recovering with a fallback value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7043,15 +7769,16 @@ export declare const orElseSucceed: { * // Output: [ "Recovered: NetworkError" ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ (self: Stream, f: (error: E) => A2): Stream; }; /** * Turns typed failures into defects, making the stream infallible. * - * @example + * **Example** (Turning failures into defects) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7068,16 +7795,25 @@ export declare const orElseSucceed: { * // Output: [ 1, 2, 3 ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ export declare const orDie: (self: Stream) => Stream; /** * Ignores failures and ends the stream on error. * - * Use the `log` option to emit the full {@link Cause} when the stream fails. + * **When to use** + * + * Use when you want a failing stream to end gracefully rather than propagate + * the error. + * + * **Details** + * + * The `log` option controls whether the failure is logged before the stream + * terminates. + * + * **Example** (Ignoring stream failures) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7094,17 +7830,26 @@ export declare const orDie: (self: Stream) => Stream console.log(values)) + * })) * - * const program = stream.pipe(Stream.ignore({ log: "Error" })) + * // [] * ``` * + * @see {@link ignoreCause} for a variant that also ignores defects, not just typed failures + * + * @category error handling * @since 4.0.0 - * @category Error Handling */ export declare const ignore: | { readonly log?: boolean | Severity | undefined; @@ -7114,22 +7859,32 @@ export declare const ignore: | { /** * Ignores the stream's failure cause, including defects, and ends the stream. * - * Use the `log` option to emit the full {@link Cause} when the stream fails. + * **When to use** + * + * Use when you need to silently suppress a stream's entire failure cause, + * including both typed errors and defects, rather than propagate it downstream. + * + * **Example** (Ignoring stream failure causes) * - * @example * ```ts * import { Effect, Stream } from "effect" * - * const stream = Stream.make(1, 2).pipe( - * Stream.concat(Stream.fail("boom")), - * Stream.ignoreCause({ log: "Error" }) - * ) + * Effect.runPromise(Effect.gen(function*() { + * const values = yield* Stream.make(1, 2).pipe( + * Stream.concat(Stream.die("boom")), + * Stream.ignoreCause({ log: false }), + * Stream.runCollect + * ) + * yield* Effect.sync(() => console.log(values)) + * })) * - * const program = Stream.runCollect(stream) + * // [ 1, 2 ] * ``` * + * @see {@link ignore} to ignore only typed failures without suppressing defects + * + * @category error handling * @since 4.0.0 - * @category Error Handling */ export declare const ignoreCause: | { readonly log?: boolean | Severity | undefined; @@ -7137,7 +7892,9 @@ export declare const ignoreCause: | { readonly log?: boolean | Severity | undefined; } | undefined) => [Arg] extends [Stream] ? Stream : (self: Stream) => Stream; /** - * When the stream fails, retry it according to the given schedule. + * Retries the stream according to the given schedule when it fails. + * + * **Details** * * This retries the entire stream, so will re-execute all of the stream's * acquire operations. @@ -7145,7 +7902,8 @@ export declare const ignoreCause: | { * The schedule is reset as soon as the first element passes through the * stream again. * - * @example + * **Example** (Retrying stream failures) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -7164,12 +7922,14 @@ export declare const ignoreCause: | { * // Output: [ 1, 1 ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ export declare const retry: { /** - * When the stream fails, retry it according to the given schedule. + * Retries the stream according to the given schedule when it fails. + * + * **Details** * * This retries the entire stream, so will re-execute all of the stream's * acquire operations. @@ -7177,7 +7937,8 @@ export declare const retry: { * The schedule is reset as soon as the first element passes through the * stream again. * - * @example + * **Example** (Retrying stream failures) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -7196,12 +7957,14 @@ export declare const retry: { * // Output: [ 1, 1 ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ (policy: Schedule.Schedule, E2, R2> | (($: (_: Schedule.Schedule, SE, SR>) => Schedule.Schedule) => Schedule.Schedule, E2, R2>)): (self: Stream) => Stream; /** - * When the stream fails, retry it according to the given schedule. + * Retries the stream according to the given schedule when it fails. + * + * **Details** * * This retries the entire stream, so will re-execute all of the stream's * acquire operations. @@ -7209,7 +7972,8 @@ export declare const retry: { * The schedule is reset as soon as the first element passes through the * stream again. * - * @example + * **Example** (Retrying stream failures) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -7228,22 +7992,25 @@ export declare const retry: { * // Output: [ 1, 1 ] * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ (self: Stream, policy: Schedule.Schedule, E2, R2> | (($: (_: Schedule.Schedule, SE, SR>) => Schedule.Schedule) => Schedule.Schedule, E2, R2>)): Stream; }; /** - * Apply an `ExecutionPlan` to a stream, retrying with step-provided resources + * Applies an `ExecutionPlan` to a stream, retrying with step-provided resources * until it succeeds or the plan is exhausted. * + * **Details** + * * By default, a failing step can fallback even after emitting elements; set * `preventFallbackOnPartialStream` to fail instead of mixing partial output with * a later fallback. * - * @example + * **Example** (Applying an execution plan) + * * ```ts - * import { Console, Effect, ExecutionPlan, Layer, Context, Stream } from "effect" + * import { Console, Context, Effect, ExecutionPlan, Layer, Stream } from "effect" * * class Service extends Context.Service()("Service", { * make: Effect.succeed({ @@ -7259,7 +8026,7 @@ export declare const retry: { * { provide: Service.Good } * ) * - * const stream = Stream.unwrap(Effect.map(Service.asEffect(), (_) => _.stream)) + * const stream = Stream.unwrap(Effect.map(Service, (_) => _.stream)) * * const program = Effect.gen(function*() { * const items = yield* stream.pipe(Stream.withExecutionPlan(plan), Stream.runCollect) @@ -7270,22 +8037,24 @@ export declare const retry: { * // Output: [ 1, 2, 3 ] * ``` * + * @category error handling * @since 3.16.0 - * @category Error Handling - * @experimental */ export declare const withExecutionPlan: { /** - * Apply an `ExecutionPlan` to a stream, retrying with step-provided resources + * Applies an `ExecutionPlan` to a stream, retrying with step-provided resources * until it succeeds or the plan is exhausted. * + * **Details** + * * By default, a failing step can fallback even after emitting elements; set * `preventFallbackOnPartialStream` to fail instead of mixing partial output with * a later fallback. * - * @example + * **Example** (Applying an execution plan) + * * ```ts - * import { Console, Effect, ExecutionPlan, Layer, Context, Stream } from "effect" + * import { Console, Context, Effect, ExecutionPlan, Layer, Stream } from "effect" * * class Service extends Context.Service()("Service", { * make: Effect.succeed({ @@ -7301,7 +8070,7 @@ export declare const withExecutionPlan: { * { provide: Service.Good } * ) * - * const stream = Stream.unwrap(Effect.map(Service.asEffect(), (_) => _.stream)) + * const stream = Stream.unwrap(Effect.map(Service, (_) => _.stream)) * * const program = Effect.gen(function*() { * const items = yield* stream.pipe(Stream.withExecutionPlan(plan), Stream.runCollect) @@ -7312,9 +8081,8 @@ export declare const withExecutionPlan: { * // Output: [ 1, 2, 3 ] * ``` * + * @category error handling * @since 3.16.0 - * @category Error Handling - * @experimental */ (policy: ExecutionPlan.ExecutionPlan<{ provides: Provides; @@ -7325,16 +8093,19 @@ export declare const withExecutionPlan: { readonly preventFallbackOnPartialStream?: boolean | undefined; }): (self: Stream) => Stream>; /** - * Apply an `ExecutionPlan` to a stream, retrying with step-provided resources + * Applies an `ExecutionPlan` to a stream, retrying with step-provided resources * until it succeeds or the plan is exhausted. * + * **Details** + * * By default, a failing step can fallback even after emitting elements; set * `preventFallbackOnPartialStream` to fail instead of mixing partial output with * a later fallback. * - * @example + * **Example** (Applying an execution plan) + * * ```ts - * import { Console, Effect, ExecutionPlan, Layer, Context, Stream } from "effect" + * import { Console, Context, Effect, ExecutionPlan, Layer, Stream } from "effect" * * class Service extends Context.Service()("Service", { * make: Effect.succeed({ @@ -7350,7 +8121,7 @@ export declare const withExecutionPlan: { * { provide: Service.Good } * ) * - * const stream = Stream.unwrap(Effect.map(Service.asEffect(), (_) => _.stream)) + * const stream = Stream.unwrap(Effect.map(Service, (_) => _.stream)) * * const program = Effect.gen(function*() { * const items = yield* stream.pipe(Stream.withExecutionPlan(plan), Stream.runCollect) @@ -7361,9 +8132,8 @@ export declare const withExecutionPlan: { * // Output: [ 1, 2, 3 ] * ``` * + * @category error handling * @since 3.16.0 - * @category Error Handling - * @experimental */ (self: Stream, policy: ExecutionPlan.ExecutionPlan<{ provides: Provides; @@ -7377,7 +8147,8 @@ export declare const withExecutionPlan: { /** * Takes the first `n` elements from this stream, returning `Stream.empty` when `n < 1`. * - * @example + * **Example** (Taking values from the left) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7393,14 +8164,15 @@ export declare const withExecutionPlan: { * // Output: [ 1, 2, 3 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const take: { /** * Takes the first `n` elements from this stream, returning `Stream.empty` when `n < 1`. * - * @example + * **Example** (Taking values from the left) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7416,14 +8188,15 @@ export declare const take: { * // Output: [ 1, 2, 3 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (n: number): (self: Stream) => Stream; /** * Takes the first `n` elements from this stream, returning `Stream.empty` when `n < 1`. * - * @example + * **Example** (Taking values from the left) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7439,15 +8212,16 @@ export declare const take: { * // Output: [ 1, 2, 3 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, n: number): Stream; }; /** * Keeps the last `n` elements from this stream. * - * @example + * **Example** (Taking elements from the right) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7463,14 +8237,15 @@ export declare const take: { * // Output: [ 4, 5, 6 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const takeRight: { /** * Keeps the last `n` elements from this stream. * - * @example + * **Example** (Taking elements from the right) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7486,14 +8261,15 @@ export declare const takeRight: { * // Output: [ 4, 5, 6 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (n: number): (self: Stream) => Stream; /** * Keeps the last `n` elements from this stream. * - * @example + * **Example** (Taking elements from the right) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7509,17 +8285,20 @@ export declare const takeRight: { * // Output: [ 4, 5, 6 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, n: number): Stream; }; /** * Takes elements until the predicate matches. * + * **Details** + * * When `excludeLast` is `true`, the matching element is dropped. * - * @example + * **Example** (Taking until a predicate matches) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7542,16 +8321,19 @@ export declare const takeRight: { * }) * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const takeUntil: { /** * Takes elements until the predicate matches. * + * **Details** + * * When `excludeLast` is `true`, the matching element is dropped. * - * @example + * **Example** (Taking until a predicate matches) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7574,8 +8356,8 @@ export declare const takeUntil: { * }) * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (predicate: (a: NoInfer, n: number) => boolean, options?: { readonly excludeLast?: boolean | undefined; @@ -7583,9 +8365,12 @@ export declare const takeUntil: { /** * Takes elements until the predicate matches. * + * **Details** + * * When `excludeLast` is `true`, the matching element is dropped. * - * @example + * **Example** (Taking until a predicate matches) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7608,17 +8393,23 @@ export declare const takeUntil: { * }) * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, predicate: (a: A, n: number) => boolean, options?: { readonly excludeLast?: boolean | undefined; }): Stream; }; /** - * Effectful predicate version of `takeUntil`. + * Takes stream elements until an effectful predicate returns `true`. + * + * **When to use** + * + * Use when the stopping condition needs an Effect or service and predicate + * failure should fail the stream. + * + * **Example** (Taking until an effectful predicate matches) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7634,14 +8425,20 @@ export declare const takeUntil: { * // Output: [ 1, 2, 3 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const takeUntilEffect: { /** - * Effectful predicate version of `takeUntil`. + * Takes stream elements until an effectful predicate returns `true`. + * + * **When to use** + * + * Use when the stopping condition needs an Effect or service and predicate + * failure should fail the stream. + * + * **Example** (Taking until an effectful predicate matches) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7657,16 +8454,22 @@ export declare const takeUntilEffect: { * // Output: [ 1, 2, 3 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (predicate: (a: NoInfer, n: number) => Effect.Effect, options?: { readonly excludeLast?: boolean | undefined; }): (self: Stream) => Stream; /** - * Effectful predicate version of `takeUntil`. + * Takes stream elements until an effectful predicate returns `true`. + * + * **When to use** + * + * Use when the stopping condition needs an Effect or service and predicate + * failure should fail the stream. + * + * **Example** (Taking until an effectful predicate matches) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7682,8 +8485,8 @@ export declare const takeUntilEffect: { * // Output: [ 1, 2, 3 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, predicate: (a: A, n: number) => Effect.Effect, options?: { readonly excludeLast?: boolean | undefined; @@ -7692,7 +8495,8 @@ export declare const takeUntilEffect: { /** * Takes the longest initial prefix of elements that satisfy the predicate. * - * @example + * **Example** (Taking while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7709,14 +8513,15 @@ export declare const takeUntilEffect: { * // Output: [ 1, 2 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const takeWhile: { /** * Takes the longest initial prefix of elements that satisfy the predicate. * - * @example + * **Example** (Taking while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7733,14 +8538,15 @@ export declare const takeWhile: { * // Output: [ 1, 2 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (refinement: (a: NoInfer, n: number) => a is B): (self: Stream) => Stream; /** * Takes the longest initial prefix of elements that satisfy the predicate. * - * @example + * **Example** (Taking while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7757,14 +8563,15 @@ export declare const takeWhile: { * // Output: [ 1, 2 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (predicate: (a: NoInfer, n: number) => boolean): (self: Stream) => Stream; /** * Takes the longest initial prefix of elements that satisfy the predicate. * - * @example + * **Example** (Taking while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7781,14 +8588,15 @@ export declare const takeWhile: { * // Output: [ 1, 2 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, refinement: (a: NoInfer, n: number) => a is B): Stream; /** * Takes the longest initial prefix of elements that satisfy the predicate. * - * @example + * **Example** (Taking while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7805,37 +8613,85 @@ export declare const takeWhile: { * // Output: [ 1, 2 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, predicate: (a: NoInfer, n: number) => boolean): Stream; }; /** - * Takes the longest initial prefix of elements that satisfy the filter. + * Takes the longest initial prefix accepted by a `Filter` and emits the + * filter's success values. + * + * **When to use** * + * Use to keep the leading stream elements that a `Filter` accepts, emit the + * filter's success values, and stop at the first filter failure. + * + * **Details** + * + * The stream stops at the first `Result.fail` returned by the filter. + * + * @see {@link takeWhile} for keeping original elements with a boolean predicate or refinement + * @see {@link filterMap} for filtering across the whole stream instead of only the leading prefix + * @see {@link dropWhileFilter} for dropping the accepted prefix and keeping the remaining original elements + * + * @category filtering * @since 4.0.0 - * @category Filtering */ export declare const takeWhileFilter: { /** - * Takes the longest initial prefix of elements that satisfy the filter. + * Takes the longest initial prefix accepted by a `Filter` and emits the + * filter's success values. * - * @since 4.0.0 - * @category Filtering - */ - (f: Filter.Filter, B, X>): (self: Stream) => Stream; - /** - * Takes the longest initial prefix of elements that satisfy the filter. + * **When to use** * + * Use to keep the leading stream elements that a `Filter` accepts, emit the + * filter's success values, and stop at the first filter failure. + * + * **Details** + * + * The stream stops at the first `Result.fail` returned by the filter. + * + * @see {@link takeWhile} for keeping original elements with a boolean predicate or refinement + * @see {@link filterMap} for filtering across the whole stream instead of only the leading prefix + * @see {@link dropWhileFilter} for dropping the accepted prefix and keeping the remaining original elements + * + * @category filtering + * @since 4.0.0 + */ + (f: Filter.Filter, B, X>): (self: Stream) => Stream; + /** + * Takes the longest initial prefix accepted by a `Filter` and emits the + * filter's success values. + * + * **When to use** + * + * Use to keep the leading stream elements that a `Filter` accepts, emit the + * filter's success values, and stop at the first filter failure. + * + * **Details** + * + * The stream stops at the first `Result.fail` returned by the filter. + * + * @see {@link takeWhile} for keeping original elements with a boolean predicate or refinement + * @see {@link filterMap} for filtering across the whole stream instead of only the leading prefix + * @see {@link dropWhileFilter} for dropping the accepted prefix and keeping the remaining original elements + * + * @category filtering * @since 4.0.0 - * @category Filtering */ (self: Stream, f: Filter.Filter, B, X>): Stream; }; /** * Takes elements from the stream while the effectful predicate is `true`. * - * @example + * **When to use** + * + * Use when the leading-prefix predicate needs an Effect or service and the + * stream should stop before the first false result. + * + * **Example** (Effectfully taking while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7851,14 +8707,20 @@ export declare const takeWhileFilter: { * // Output: [ 1, 2 ] * ``` * - * @since 2.0.0 - * @category Filtering + * @category filtering + * @since 4.0.0 */ export declare const takeWhileEffect: { /** * Takes elements from the stream while the effectful predicate is `true`. * - * @example + * **When to use** + * + * Use when the leading-prefix predicate needs an Effect or service and the + * stream should stop before the first false result. + * + * **Example** (Effectfully taking while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7874,14 +8736,20 @@ export declare const takeWhileEffect: { * // Output: [ 1, 2 ] * ``` * - * @since 2.0.0 - * @category Filtering + * @category filtering + * @since 4.0.0 */ (predicate: (a: NoInfer, n: number) => Effect.Effect): (self: Stream) => Stream; /** * Takes elements from the stream while the effectful predicate is `true`. * - * @example + * **When to use** + * + * Use when the leading-prefix predicate needs an Effect or service and the + * stream should stop before the first false result. + * + * **Example** (Effectfully taking while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7897,15 +8765,16 @@ export declare const takeWhileEffect: { * // Output: [ 1, 2 ] * ``` * - * @since 2.0.0 - * @category Filtering + * @category filtering + * @since 4.0.0 */ (self: Stream, predicate: (a: NoInfer, n: number) => Effect.Effect): Stream; }; /** * Drops the first `n` elements from this stream. * - * @example + * **Example** (Dropping values from the left) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7921,14 +8790,15 @@ export declare const takeWhileEffect: { * // Output: [ 3, 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const drop: { /** * Drops the first `n` elements from this stream. * - * @example + * **Example** (Dropping values from the left) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7944,14 +8814,15 @@ export declare const drop: { * // Output: [ 3, 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (n: number): (self: Stream) => Stream; /** * Drops the first `n` elements from this stream. * - * @example + * **Example** (Dropping values from the left) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7967,8 +8838,8 @@ export declare const drop: { * // Output: [ 3, 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, n: number): Stream; }; @@ -7976,7 +8847,8 @@ export declare const drop: { * Drops elements until the specified predicate evaluates to `true`, then drops * that matching element. * - * @example + * **Example** (Dropping until a predicate matches) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -7989,15 +8861,16 @@ export declare const drop: { * }) * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const dropUntil: { /** * Drops elements until the specified predicate evaluates to `true`, then drops * that matching element. * - * @example + * **Example** (Dropping until a predicate matches) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8010,15 +8883,16 @@ export declare const dropUntil: { * }) * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (predicate: (a: NoInfer, index: number) => boolean): (self: Stream) => Stream; /** * Drops elements until the specified predicate evaluates to `true`, then drops * that matching element. * - * @example + * **Example** (Dropping until a predicate matches) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8031,8 +8905,8 @@ export declare const dropUntil: { * }) * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, predicate: (a: NoInfer, index: number) => boolean): Stream; }; @@ -8040,9 +8914,13 @@ export declare const dropUntil: { * Drops all elements of the stream until the specified effectful predicate * evaluates to `true`. * - * The first element that satisfies the predicate is also dropped. + * **When to use** + * + * Use when dropping the leading prefix requires an Effect or service and the + * first matching element should also be dropped. + * + * **Example** (Dropping until an effectful predicate matches) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8058,17 +8936,21 @@ export declare const dropUntil: { * // Output: [ 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const dropUntilEffect: { /** * Drops all elements of the stream until the specified effectful predicate * evaluates to `true`. * - * The first element that satisfies the predicate is also dropped. + * **When to use** + * + * Use when dropping the leading prefix requires an Effect or service and the + * first matching element should also be dropped. + * + * **Example** (Dropping until an effectful predicate matches) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8084,17 +8966,21 @@ export declare const dropUntilEffect: { * // Output: [ 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (predicate: (a: NoInfer, index: number) => Effect.Effect): (self: Stream) => Stream; /** * Drops all elements of the stream until the specified effectful predicate * evaluates to `true`. * - * The first element that satisfies the predicate is also dropped. + * **When to use** + * + * Use when dropping the leading prefix requires an Effect or service and the + * first matching element should also be dropped. + * + * **Example** (Dropping until an effectful predicate matches) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8110,15 +8996,16 @@ export declare const dropUntilEffect: { * // Output: [ 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, predicate: (a: NoInfer, index: number) => Effect.Effect): Stream; }; /** * Drops elements from the stream while the specified predicate evaluates to `true`. * - * @example + * **Example** (Dropping while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8134,14 +9021,15 @@ export declare const dropUntilEffect: { * // Output: [ 3, 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const dropWhile: { /** * Drops elements from the stream while the specified predicate evaluates to `true`. * - * @example + * **Example** (Dropping while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8157,14 +9045,15 @@ export declare const dropWhile: { * // Output: [ 3, 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (predicate: (a: NoInfer, index: number) => boolean): (self: Stream) => Stream; /** * Drops elements from the stream while the specified predicate evaluates to `true`. * - * @example + * **Example** (Dropping while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8180,37 +9069,83 @@ export declare const dropWhile: { * // Output: [ 3, 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, predicate: (a: NoInfer, index: number) => boolean): Stream; }; /** * Drops elements while the filter succeeds. * + * **When to use** + * + * Use when you need to remove a leading stream prefix based on a synchronous + * `Filter` result while preserving the remaining original stream elements. + * + * **Details** + * + * `Result.succeed` drops the current element. The first `Result.fail` stops + * dropping, emits that original element, and the rest of the source stream is + * emitted without further filtering. + * + * @see {@link dropWhile} for boolean predicate prefix dropping + * @see {@link takeWhileFilter} for keeping the accepted prefix as filter success values + * @see {@link dropWhileEffect} for effectful predicate prefix dropping + * + * @category filtering * @since 4.0.0 - * @category Filtering */ export declare const dropWhileFilter: { /** * Drops elements while the filter succeeds. * + * **When to use** + * + * Use when you need to remove a leading stream prefix based on a synchronous + * `Filter` result while preserving the remaining original stream elements. + * + * **Details** + * + * `Result.succeed` drops the current element. The first `Result.fail` stops + * dropping, emits that original element, and the rest of the source stream is + * emitted without further filtering. + * + * @see {@link dropWhile} for boolean predicate prefix dropping + * @see {@link takeWhileFilter} for keeping the accepted prefix as filter success values + * @see {@link dropWhileEffect} for effectful predicate prefix dropping + * + * @category filtering * @since 4.0.0 - * @category Filtering */ (filter: Filter.Filter, B, X>): (self: Stream) => Stream; /** * Drops elements while the filter succeeds. * + * **When to use** + * + * Use when you need to remove a leading stream prefix based on a synchronous + * `Filter` result while preserving the remaining original stream elements. + * + * **Details** + * + * `Result.succeed` drops the current element. The first `Result.fail` stops + * dropping, emits that original element, and the rest of the source stream is + * emitted without further filtering. + * + * @see {@link dropWhile} for boolean predicate prefix dropping + * @see {@link takeWhileFilter} for keeping the accepted prefix as filter success values + * @see {@link dropWhileEffect} for effectful predicate prefix dropping + * + * @category filtering * @since 4.0.0 - * @category Filtering */ (self: Stream, filter: Filter.Filter, B, X>): Stream; }; /** * Drops elements while the specified effectful predicate evaluates to `true`. * - * @example + * **Example** (Effectfully dropping while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8226,14 +9161,15 @@ export declare const dropWhileFilter: { * // Output: [ 3, 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const dropWhileEffect: { /** * Drops elements while the specified effectful predicate evaluates to `true`. * - * @example + * **Example** (Effectfully dropping while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8249,14 +9185,15 @@ export declare const dropWhileEffect: { * // Output: [ 3, 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (predicate: (a: NoInfer, index: number) => Effect.Effect): (self: Stream) => Stream; /** * Drops elements while the specified effectful predicate evaluates to `true`. * - * @example + * **Example** (Effectfully dropping while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8272,17 +9209,20 @@ export declare const dropWhileEffect: { * // Output: [ 3, 4, 5 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, predicate: (a: A, index: number) => Effect.Effect): Stream; }; /** * Drops the last specified number of elements from this stream. * + * **Details** + * * Keeps the last `n` elements in memory to drop them on completion. * - * @example + * **Example** (Dropping values from the right) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8298,16 +9238,19 @@ export declare const dropWhileEffect: { * // Output: [ 1, 2, 3 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ export declare const dropRight: { /** * Drops the last specified number of elements from this stream. * + * **Details** + * * Keeps the last `n` elements in memory to drop them on completion. * - * @example + * **Example** (Dropping values from the right) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8323,16 +9266,19 @@ export declare const dropRight: { * // Output: [ 1, 2, 3 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (n: number): (self: Stream) => Stream; /** * Drops the last specified number of elements from this stream. * + * **Details** + * * Keeps the last `n` elements in memory to drop them on completion. * - * @example + * **Example** (Dropping values from the right) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8348,15 +9294,16 @@ export declare const dropRight: { * // Output: [ 1, 2, 3 ] * ``` * + * @category filtering * @since 2.0.0 - * @category Filtering */ (self: Stream, n: number): Stream; }; /** * Exposes the underlying chunks as a stream of non-empty arrays. * - * @example + * **Example** (Exposing stream chunks) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8373,16 +9320,19 @@ export declare const dropRight: { * // Output: [ [ 1, 2 ], [ 3, 4 ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ export declare const chunks: (self: Stream) => Stream, E, R>; /** - * Re-chunks the stream into arrays of the specified size, preserving element order. + * Groups the stream into arrays of the specified size, preserving element order. + * + * **Details** * * The size is clamped to at least 1. * - * @example + * **Example** (Rechunking stream elements) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8399,16 +9349,19 @@ export declare const chunks: (self: Stream) => Stream(self: Stream) => Stream; /** - * Re-chunks the stream into arrays of the specified size, preserving element order. + * Groups the stream into arrays of the specified size, preserving element order. + * + * **Details** * * The size is clamped to at least 1. * - * @example + * **Example** (Rechunking stream elements) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8451,17 +9407,18 @@ export declare const rechunk: { * // Output: [ [ 1, 2 ], [ 3, 4 ], [ 5 ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (self: Stream, size: number): Stream; }; /** * Emits a sliding window of `n` elements. * - * @example + * **Example** (Emitting sliding windows) + * * ```ts - * import { Console, Effect, Stream, pipe } from "effect" + * import { Console, Effect, pipe, Stream } from "effect" * * Effect.gen(function*() { * const result = yield* pipe( @@ -8474,16 +9431,17 @@ export declare const rechunk: { * // Output: [ [1, 2], [2, 3], [3, 4], [4, 5] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ export declare const sliding: { /** * Emits a sliding window of `n` elements. * - * @example + * **Example** (Emitting sliding windows) + * * ```ts - * import { Console, Effect, Stream, pipe } from "effect" + * import { Console, Effect, pipe, Stream } from "effect" * * Effect.gen(function*() { * const result = yield* pipe( @@ -8496,16 +9454,17 @@ export declare const sliding: { * // Output: [ [1, 2], [2, 3], [3, 4], [4, 5] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (chunkSize: number): (self: Stream) => Stream, E, R>; /** * Emits a sliding window of `n` elements. * - * @example + * **Example** (Emitting sliding windows) + * * ```ts - * import { Console, Effect, Stream, pipe } from "effect" + * import { Console, Effect, pipe, Stream } from "effect" * * Effect.gen(function*() { * const result = yield* pipe( @@ -8518,14 +9477,16 @@ export declare const sliding: { * // Output: [ [1, 2], [2, 3], [3, 4], [4, 5] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (self: Stream, chunkSize: number): Stream, E, R>; }; /** * Emits sliding windows of `chunkSize` elements, advancing by `stepSize`. * + * **Example** (Emitting sliding windows with a step size) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8541,13 +9502,15 @@ export declare const sliding: { * // Output: [ [ 1, 2, 3 ], [ 3, 4, 5 ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ export declare const slidingSize: { /** * Emits sliding windows of `chunkSize` elements, advancing by `stepSize`. * + * **Example** (Emitting sliding windows with a step size) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8563,13 +9526,15 @@ export declare const slidingSize: { * // Output: [ [ 1, 2, 3 ], [ 3, 4, 5 ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (chunkSize: number, stepSize: number): (self: Stream) => Stream, E, R>; /** * Emits sliding windows of `chunkSize` elements, advancing by `stepSize`. * + * **Example** (Emitting sliding windows with a step size) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8585,17 +9550,20 @@ export declare const slidingSize: { * // Output: [ [ 1, 2, 3 ], [ 3, 4, 5 ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (self: Stream, chunkSize: number, stepSize: number): Stream, E, R>; }; /** * Splits the stream into non-empty groups whenever the predicate matches. * + * **Details** + * * Matching elements act as delimiters and are not included in the output. * - * @example + * **Example** (Splitting on matching values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8611,16 +9579,19 @@ export declare const slidingSize: { * // Output: [ [1, 2, 3], [5, 6, 7], [9] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ export declare const split: { /** * Splits the stream into non-empty groups whenever the predicate matches. * + * **Details** + * * Matching elements act as delimiters and are not included in the output. * - * @example + * **Example** (Splitting on matching values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8636,16 +9607,19 @@ export declare const split: { * // Output: [ [1, 2, 3], [5, 6, 7], [9] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (refinement: Refinement, B>): (self: Stream) => Stream>, E, R>; /** * Splits the stream into non-empty groups whenever the predicate matches. * + * **Details** + * * Matching elements act as delimiters and are not included in the output. * - * @example + * **Example** (Splitting on matching values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8661,16 +9635,19 @@ export declare const split: { * // Output: [ [1, 2, 3], [5, 6, 7], [9] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (predicate: Predicate>): (self: Stream) => Stream, E, R>; /** * Splits the stream into non-empty groups whenever the predicate matches. * + * **Details** + * * Matching elements act as delimiters and are not included in the output. * - * @example + * **Example** (Splitting on matching values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8686,16 +9663,19 @@ export declare const split: { * // Output: [ [1, 2, 3], [5, 6, 7], [9] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (self: Stream, refinement: Refinement): Stream>, E, R>; /** * Splits the stream into non-empty groups whenever the predicate matches. * + * **Details** + * * Matching elements act as delimiters and are not included in the output. * - * @example + * **Example** (Splitting on matching values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8711,8 +9691,8 @@ export declare const split: { * // Output: [ [1, 2, 3], [5, 6, 7], [9] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (self: Stream, predicate: Predicate): Stream, E, R>; }; @@ -8720,10 +9700,13 @@ export declare const split: { * Combines elements from this stream and the specified stream by repeatedly * applying a stateful function that can pull from either side. * + * **Details** + * * Where possible, prefer `Stream.combineArray` for a more efficient * implementation. * - * @example + * **Example** (Combining streams with state) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8746,18 +9729,21 @@ export declare const split: { * // Output: [ "L:A", "R:1", "L:B", "R:2", "L:C", "R:3" ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ export declare const combine: { /** * Combines elements from this stream and the specified stream by repeatedly * applying a stateful function that can pull from either side. * + * **Details** + * * Where possible, prefer `Stream.combineArray` for a more efficient * implementation. * - * @example + * **Example** (Combining streams with state) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8780,18 +9766,21 @@ export declare const combine: { * // Output: [ "L:A", "R:1", "L:B", "R:2", "L:C", "R:3" ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ (that: Stream, s: LazyArg, f: (s: S, pullLeft: Pull.Pull, pullRight: Pull.Pull) => Effect.Effect): (self: Stream) => Stream; /** * Combines elements from this stream and the specified stream by repeatedly * applying a stateful function that can pull from either side. * + * **Details** + * * Where possible, prefer `Stream.combineArray` for a more efficient * implementation. * - * @example + * **Example** (Combining streams with state) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8814,25 +9803,27 @@ export declare const combine: { * // Output: [ "L:A", "R:1", "L:B", "R:2", "L:C", "R:3" ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ (self: Stream, that: Stream, s: LazyArg, f: (s: S, pullLeft: Pull.Pull, pullRight: Pull.Pull) => Effect.Effect): Stream; }; /** - * Combines the arrays (chunks) from this stream and the specified stream by - * repeatedly applying the function `f` to extract an array using both sides and - * conceptually "offer" it to the destination stream. `f` can maintain some - * internal state to control the combining process, with the initial state - * being specified by `s`. + * Combines two streams chunk-by-chunk with a stateful pull function. + * + * **When to use** * - * **Previously Known As** + * Use to coordinate pulling chunks from two streams when each emitted chunk + * depends on both sides and local state. * - * This API replaces the following from Effect 3.x: + * **Details** * - * - `Stream.combineChunks` + * The combining function receives the current state and pull functions for the + * left and right streams. It returns the next non-empty chunk together with the + * next state. + * + * **Example** (Combining stream chunks with state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8857,24 +9848,26 @@ export declare const combine: { * // Output: [ 1, 2, 10, 20 ] * ``` * - * @since 2.0.0 - * @category Sequencing + * @category sequencing + * @since 4.0.0 */ export declare const combineArray: { /** - * Combines the arrays (chunks) from this stream and the specified stream by - * repeatedly applying the function `f` to extract an array using both sides and - * conceptually "offer" it to the destination stream. `f` can maintain some - * internal state to control the combining process, with the initial state - * being specified by `s`. + * Combines two streams chunk-by-chunk with a stateful pull function. + * + * **When to use** * - * **Previously Known As** + * Use to coordinate pulling chunks from two streams when each emitted chunk + * depends on both sides and local state. * - * This API replaces the following from Effect 3.x: + * **Details** * - * - `Stream.combineChunks` + * The combining function receives the current state and pull functions for the + * left and right streams. It returns the next non-empty chunk together with the + * next state. + * + * **Example** (Combining stream chunks with state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8899,24 +9892,26 @@ export declare const combineArray: { * // Output: [ 1, 2, 10, 20 ] * ``` * - * @since 2.0.0 - * @category Sequencing + * @category sequencing + * @since 4.0.0 */ (that: Stream, s: LazyArg, f: (s: S, pullLeft: Pull.Pull, E, void>, pullRight: Pull.Pull, E2, void>) => Effect.Effect, S], E3, R3>): (self: Stream) => Stream, R2 | R3 | R>; /** - * Combines the arrays (chunks) from this stream and the specified stream by - * repeatedly applying the function `f` to extract an array using both sides and - * conceptually "offer" it to the destination stream. `f` can maintain some - * internal state to control the combining process, with the initial state - * being specified by `s`. + * Combines two streams chunk-by-chunk with a stateful pull function. + * + * **When to use** * - * **Previously Known As** + * Use to coordinate pulling chunks from two streams when each emitted chunk + * depends on both sides and local state. * - * This API replaces the following from Effect 3.x: + * **Details** * - * - `Stream.combineChunks` + * The combining function receives the current state and pull functions for the + * left and right streams. It returns the next non-empty chunk together with the + * next state. + * + * **Example** (Combining stream chunks with state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8941,15 +9936,16 @@ export declare const combineArray: { * // Output: [ 1, 2, 10, 20 ] * ``` * - * @since 2.0.0 - * @category Sequencing + * @category sequencing + * @since 4.0.0 */ (self: Stream, that: Stream, s: LazyArg, f: (s: S, pullLeft: Pull.Pull, E, void>, pullRight: Pull.Pull, E2, void>) => Effect.Effect, S], E3, R3>): Stream, R | R2 | R3>; }; /** - * Statefully maps elements, emitting zero or more outputs per input. + * Maps elements statefully, emitting zero or more outputs per input. + * + * **Example** (Statefully mapping stream values) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8969,14 +9965,15 @@ export declare const combineArray: { * // Output: [ 0, 1, 3, 6, 10, 15, 21 ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ export declare const mapAccum: { /** - * Statefully maps elements, emitting zero or more outputs per input. + * Maps elements statefully, emitting zero or more outputs per input. + * + * **Example** (Statefully mapping stream values) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -8996,16 +9993,17 @@ export declare const mapAccum: { * // Output: [ 0, 1, 3, 6, 10, 15, 21 ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ (initial: LazyArg, f: (s: S, a: A) => readonly [state: S, values: ReadonlyArray], options?: { readonly onHalt?: ((state: S) => ReadonlyArray) | undefined; }): (self: Stream) => Stream; /** - * Statefully maps elements, emitting zero or more outputs per input. + * Maps elements statefully, emitting zero or more outputs per input. + * + * **Example** (Statefully mapping stream values) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9025,19 +10023,22 @@ export declare const mapAccum: { * // Output: [ 0, 1, 3, 6, 10, 15, 21 ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ (self: Stream, initial: LazyArg, f: (s: S, a: A) => readonly [state: S, values: ReadonlyArray], options?: { readonly onHalt?: ((state: S) => ReadonlyArray) | undefined; }): Stream; }; /** - * Statefully maps over non-empty chunk arrays, emitting zero or more values per chunk. + * Maps over non-empty chunk arrays statefully, emitting zero or more values per chunk. + * + * **Details** * * The mapping function runs once per chunk and the state is threaded across chunks. * - * @example + * **Example** (Statefully mapping stream chunks) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9057,16 +10058,19 @@ export declare const mapAccum: { * // Output: [ 3, 10, 21 ] * ``` * - * @since 2.0.0 - * @category Mapping + * @category mapping + * @since 4.0.0 */ export declare const mapAccumArray: { /** - * Statefully maps over non-empty chunk arrays, emitting zero or more values per chunk. + * Maps over non-empty chunk arrays statefully, emitting zero or more values per chunk. + * + * **Details** * * The mapping function runs once per chunk and the state is threaded across chunks. * - * @example + * **Example** (Statefully mapping stream chunks) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9086,18 +10090,21 @@ export declare const mapAccumArray: { * // Output: [ 3, 10, 21 ] * ``` * - * @since 2.0.0 - * @category Mapping + * @category mapping + * @since 4.0.0 */ (initial: LazyArg, f: (s: S, a: Arr.NonEmptyReadonlyArray) => readonly [state: S, values: ReadonlyArray], options?: { readonly onHalt?: ((state: S) => ReadonlyArray) | undefined; }): (self: Stream) => Stream; /** - * Statefully maps over non-empty chunk arrays, emitting zero or more values per chunk. + * Maps over non-empty chunk arrays statefully, emitting zero or more values per chunk. + * + * **Details** * * The mapping function runs once per chunk and the state is threaded across chunks. * - * @example + * **Example** (Statefully mapping stream chunks) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9117,17 +10124,30 @@ export declare const mapAccumArray: { * // Output: [ 3, 10, 21 ] * ``` * - * @since 2.0.0 - * @category Mapping + * @category mapping + * @since 4.0.0 */ (self: Stream, initial: LazyArg, f: (s: S, a: Arr.NonEmptyReadonlyArray) => readonly [state: S, values: ReadonlyArray], options?: { readonly onHalt?: ((state: S) => Array) | undefined; }): Stream; }; /** - * Statefully and effectfully maps over the elements of this stream to produce new elements. + * Maps each element statefully and effectfully, emitting zero or more output + * values per input. + * + * **When to use** + * + * Use when stateful element mapping needs Effects or can fail while emitting + * zero or more values per input element. + * + * **Details** + * + * The mapping effect receives the current state and element, then returns the + * next state plus the values to emit. The state is threaded through the + * stream. + * + * **Example** (Effectfully mapping stream values with state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9146,14 +10166,27 @@ export declare const mapAccumArray: { * // Output: [ 1, 2, 3 ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ export declare const mapAccumEffect: { /** - * Statefully and effectfully maps over the elements of this stream to produce new elements. + * Maps each element statefully and effectfully, emitting zero or more output + * values per input. + * + * **When to use** + * + * Use when stateful element mapping needs Effects or can fail while emitting + * zero or more values per input element. + * + * **Details** + * + * The mapping effect receives the current state and element, then returns the + * next state plus the values to emit. The state is threaded through the + * stream. + * + * **Example** (Effectfully mapping stream values with state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9172,16 +10205,29 @@ export declare const mapAccumEffect: { * // Output: [ 1, 2, 3 ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ (initial: LazyArg, f: (s: S, a: A) => Effect.Effect], E2, R2>, options?: { readonly onHalt?: ((state: S) => ReadonlyArray) | undefined; }): (self: Stream) => Stream; /** - * Statefully and effectfully maps over the elements of this stream to produce new elements. + * Maps each element statefully and effectfully, emitting zero or more output + * values per input. + * + * **When to use** + * + * Use when stateful element mapping needs Effects or can fail while emitting + * zero or more values per input element. + * + * **Details** + * + * The mapping effect receives the current state and element, then returns the + * next state plus the values to emit. The state is threaded through the + * stream. + * + * **Example** (Effectfully mapping stream values with state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9200,17 +10246,29 @@ export declare const mapAccumEffect: { * // Output: [ 1, 2, 3 ] * ``` * + * @category mapping * @since 2.0.0 - * @category Mapping */ (self: Stream, initial: LazyArg, f: (s: S, a: A) => Effect.Effect], E2, R2>, options?: { readonly onHalt?: ((state: S) => ReadonlyArray) | undefined; }): Stream; }; /** - * Statefully and effectfully maps over chunks of this stream to emit new values. + * Maps each non-empty input chunk statefully and effectfully, emitting zero or + * more output values per chunk. + * + * **When to use** + * + * Use when stateful mapping should process each emitted non-empty chunk with an + * Effect instead of each element separately. + * + * **Details** + * + * The mapping effect receives the current state and chunk, then returns the + * next state plus the values to emit. The state is threaded across chunks. + * + * **Example** (Effectfully mapping stream chunks with state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9232,14 +10290,26 @@ export declare const mapAccumEffect: { * // Output: [ 3, 10 ] * ``` * - * @since 2.0.0 - * @category Mapping + * @category mapping + * @since 4.0.0 */ export declare const mapAccumArrayEffect: { /** - * Statefully and effectfully maps over chunks of this stream to emit new values. + * Maps each non-empty input chunk statefully and effectfully, emitting zero or + * more output values per chunk. + * + * **When to use** + * + * Use when stateful mapping should process each emitted non-empty chunk with an + * Effect instead of each element separately. + * + * **Details** + * + * The mapping effect receives the current state and chunk, then returns the + * next state plus the values to emit. The state is threaded across chunks. + * + * **Example** (Effectfully mapping stream chunks with state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9261,16 +10331,28 @@ export declare const mapAccumArrayEffect: { * // Output: [ 3, 10 ] * ``` * - * @since 2.0.0 - * @category Mapping + * @category mapping + * @since 4.0.0 */ (initial: LazyArg, f: (s: S, a: Arr.NonEmptyReadonlyArray) => Effect.Effect], E2, R2>, options?: { readonly onHalt?: ((state: S) => ReadonlyArray) | undefined; }): (self: Stream) => Stream; /** - * Statefully and effectfully maps over chunks of this stream to emit new values. + * Maps each non-empty input chunk statefully and effectfully, emitting zero or + * more output values per chunk. + * + * **When to use** + * + * Use when stateful mapping should process each emitted non-empty chunk with an + * Effect instead of each element separately. + * + * **Details** + * + * The mapping effect receives the current state and chunk, then returns the + * next state plus the values to emit. The state is threaded across chunks. + * + * **Example** (Effectfully mapping stream chunks with state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9292,8 +10374,8 @@ export declare const mapAccumArrayEffect: { * // Output: [ 3, 10 ] * ``` * - * @since 2.0.0 - * @category Mapping + * @category mapping + * @since 4.0.0 */ (self: Stream, initial: LazyArg, f: (s: S, a: Arr.NonEmptyReadonlyArray) => Effect.Effect], E2, R2>, options?: { readonly onHalt?: ((state: S) => ReadonlyArray) | undefined; @@ -9302,7 +10384,8 @@ export declare const mapAccumArrayEffect: { /** * Accumulates state across the stream, emitting the initial state and each updated state. * - * @example + * **Example** (Scanning stream state) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9318,14 +10401,15 @@ export declare const mapAccumArrayEffect: { * // Output: [ 0, 1, 3, 6 ] * ``` * - * @since 2.0.0 * @category Accumulation + * @since 2.0.0 */ export declare const scan: { /** * Accumulates state across the stream, emitting the initial state and each updated state. * - * @example + * **Example** (Scanning stream state) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9341,14 +10425,15 @@ export declare const scan: { * // Output: [ 0, 1, 3, 6 ] * ``` * - * @since 2.0.0 * @category Accumulation + * @since 2.0.0 */ (initial: S, f: (s: S, a: A) => S): (self: Stream) => Stream; /** * Accumulates state across the stream, emitting the initial state and each updated state. * - * @example + * **Example** (Scanning stream state) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9364,15 +10449,16 @@ export declare const scan: { * // Output: [ 0, 1, 3, 6 ] * ``` * - * @since 2.0.0 * @category Accumulation + * @since 2.0.0 */ (self: Stream, initial: S, f: (s: S, a: A) => S): Stream; }; /** - * Effectfully accumulates state and emits the initial state plus each accumulated state. + * Accumulates state effectfully and emits the initial state plus each accumulated state. + * + * **Example** (Effectfully scanning stream state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9386,14 +10472,15 @@ export declare const scan: { * }) * ``` * - * @since 2.0.0 * @category Accumulation + * @since 2.0.0 */ export declare const scanEffect: { /** - * Effectfully accumulates state and emits the initial state plus each accumulated state. + * Accumulates state effectfully and emits the initial state plus each accumulated state. + * + * **Example** (Effectfully scanning stream state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9407,14 +10494,15 @@ export declare const scanEffect: { * }) * ``` * - * @since 2.0.0 * @category Accumulation + * @since 2.0.0 */ (initial: S, f: (s: S, a: A) => Effect.Effect): (self: Stream) => Stream; /** - * Effectfully accumulates state and emits the initial state plus each accumulated state. + * Accumulates state effectfully and emits the initial state plus each accumulated state. + * + * **Example** (Effectfully scanning stream state) * - * @example * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9428,15 +10516,16 @@ export declare const scanEffect: { * }) * ``` * - * @since 2.0.0 * @category Accumulation + * @since 2.0.0 */ (self: Stream, initial: S, f: (s: S, a: A) => Effect.Effect): Stream; }; /** * Drops earlier elements within the debounce window and emits only the latest element after the pause. * - * @example + * **Example** (Debouncing stream elements) + * * ```ts * import { Console, Duration, Effect, Stream } from "effect" * @@ -9453,14 +10542,15 @@ export declare const scanEffect: { * }) * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ export declare const debounce: { /** * Drops earlier elements within the debounce window and emits only the latest element after the pause. * - * @example + * **Example** (Debouncing stream elements) + * * ```ts * import { Console, Duration, Effect, Stream } from "effect" * @@ -9477,14 +10567,15 @@ export declare const debounce: { * }) * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (duration: Duration.Input): (self: Stream) => Stream; /** * Drops earlier elements within the debounce window and emits only the latest element after the pause. * - * @example + * **Example** (Debouncing stream elements) + * * ```ts * import { Console, Duration, Effect, Stream } from "effect" * @@ -9501,16 +10592,22 @@ export declare const debounce: { * }) * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (self: Stream, duration: Duration.Input): Stream; }; /** - * Delays the arrays of this stream according to the given bandwidth - * parameters using the token bucket algorithm. Allows for burst processing by - * allowing the bucket to accumulate tokens up to a `units + burst` threshold. - * The weight of each array is determined by the effectful `cost` function. + * Rate-limits stream chunks with an effectful cost function. + * + * **When to use** + * + * Use to throttle chunks when computing each chunk's cost requires an effect. + * + * **Details** + * + * Uses a token bucket. The bucket can accumulate up to `units + burst` tokens, + * and each chunk consumes the cost returned by the effectful `cost` function. * * If using the "enforce" strategy, arrays that do not meet the bandwidth * constraints are dropped. If using the "shape" strategy, arrays are delayed @@ -9518,7 +10615,8 @@ export declare const debounce: { * * Defaults to the "shape" strategy. * - * @example + * **Example** (Throttling stream chunks effectfully) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -9539,15 +10637,21 @@ export declare const debounce: { * // Output: [0, 1, 2, 3, 4, 5] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ export declare const throttleEffect: { /** - * Delays the arrays of this stream according to the given bandwidth - * parameters using the token bucket algorithm. Allows for burst processing by - * allowing the bucket to accumulate tokens up to a `units + burst` threshold. - * The weight of each array is determined by the effectful `cost` function. + * Rate-limits stream chunks with an effectful cost function. + * + * **When to use** + * + * Use to throttle chunks when computing each chunk's cost requires an effect. + * + * **Details** + * + * Uses a token bucket. The bucket can accumulate up to `units + burst` tokens, + * and each chunk consumes the cost returned by the effectful `cost` function. * * If using the "enforce" strategy, arrays that do not meet the bandwidth * constraints are dropped. If using the "shape" strategy, arrays are delayed @@ -9555,7 +10659,8 @@ export declare const throttleEffect: { * * Defaults to the "shape" strategy. * - * @example + * **Example** (Throttling stream chunks effectfully) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -9576,8 +10681,8 @@ export declare const throttleEffect: { * // Output: [0, 1, 2, 3, 4, 5] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (options: { readonly cost: (arr: Arr.NonEmptyReadonlyArray) => Effect.Effect; @@ -9587,10 +10692,16 @@ export declare const throttleEffect: { readonly strategy?: "enforce" | "shape" | undefined; }): (self: Stream) => Stream; /** - * Delays the arrays of this stream according to the given bandwidth - * parameters using the token bucket algorithm. Allows for burst processing by - * allowing the bucket to accumulate tokens up to a `units + burst` threshold. - * The weight of each array is determined by the effectful `cost` function. + * Rate-limits stream chunks with an effectful cost function. + * + * **When to use** + * + * Use to throttle chunks when computing each chunk's cost requires an effect. + * + * **Details** + * + * Uses a token bucket. The bucket can accumulate up to `units + burst` tokens, + * and each chunk consumes the cost returned by the effectful `cost` function. * * If using the "enforce" strategy, arrays that do not meet the bandwidth * constraints are dropped. If using the "shape" strategy, arrays are delayed @@ -9598,7 +10709,8 @@ export declare const throttleEffect: { * * Defaults to the "shape" strategy. * - * @example + * **Example** (Throttling stream chunks effectfully) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -9619,8 +10731,8 @@ export declare const throttleEffect: { * // Output: [0, 1, 2, 3, 4, 5] * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (self: Stream, options: { readonly cost: (arr: Arr.NonEmptyReadonlyArray) => Effect.Effect; @@ -9631,9 +10743,16 @@ export declare const throttleEffect: { }): Stream; }; /** - * Delays the arrays of this stream using a token bucket and a per-array cost. - * Allows bursts by letting the bucket accumulate up to a `units + burst` - * threshold. The weight of each array is determined by the `cost` function. + * Rate-limits stream chunks with a synchronous cost function. + * + * **When to use** + * + * Use to throttle chunks when each chunk's cost can be computed synchronously. + * + * **Details** + * + * Uses a token bucket. The bucket can accumulate up to `units + burst` tokens, + * and each chunk consumes the cost returned by `cost`. * * If using the "enforce" strategy, arrays that do not meet the bandwidth * constraints are dropped. If using the "shape" strategy, arrays are delayed @@ -9641,7 +10760,8 @@ export declare const throttleEffect: { * * Defaults to the "shape" strategy. * - * @example + * **Example** (Throttling stream chunks) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -9662,14 +10782,21 @@ export declare const throttleEffect: { * }) * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ export declare const throttle: { /** - * Delays the arrays of this stream using a token bucket and a per-array cost. - * Allows bursts by letting the bucket accumulate up to a `units + burst` - * threshold. The weight of each array is determined by the `cost` function. + * Rate-limits stream chunks with a synchronous cost function. + * + * **When to use** + * + * Use to throttle chunks when each chunk's cost can be computed synchronously. + * + * **Details** + * + * Uses a token bucket. The bucket can accumulate up to `units + burst` tokens, + * and each chunk consumes the cost returned by `cost`. * * If using the "enforce" strategy, arrays that do not meet the bandwidth * constraints are dropped. If using the "shape" strategy, arrays are delayed @@ -9677,7 +10804,8 @@ export declare const throttle: { * * Defaults to the "shape" strategy. * - * @example + * **Example** (Throttling stream chunks) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -9698,8 +10826,8 @@ export declare const throttle: { * }) * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (options: { readonly cost: (arr: Arr.NonEmptyReadonlyArray) => number; @@ -9709,9 +10837,16 @@ export declare const throttle: { readonly strategy?: "enforce" | "shape" | undefined; }): (self: Stream) => Stream; /** - * Delays the arrays of this stream using a token bucket and a per-array cost. - * Allows bursts by letting the bucket accumulate up to a `units + burst` - * threshold. The weight of each array is determined by the `cost` function. + * Rate-limits stream chunks with a synchronous cost function. + * + * **When to use** + * + * Use to throttle chunks when each chunk's cost can be computed synchronously. + * + * **Details** + * + * Uses a token bucket. The bucket can accumulate up to `units + burst` tokens, + * and each chunk consumes the cost returned by `cost`. * * If using the "enforce" strategy, arrays that do not meet the bandwidth * constraints are dropped. If using the "shape" strategy, arrays are delayed @@ -9719,7 +10854,8 @@ export declare const throttle: { * * Defaults to the "shape" strategy. * - * @example + * **Example** (Throttling stream chunks) + * * ```ts * import { Console, Effect, Schedule, Stream } from "effect" * @@ -9740,8 +10876,8 @@ export declare const throttle: { * }) * ``` * + * @category rate limiting * @since 2.0.0 - * @category Rate Limiting */ (self: Stream, options: { readonly cost: (arr: Arr.NonEmptyReadonlyArray) => number; @@ -9754,9 +10890,12 @@ export declare const throttle: { /** * Partitions the stream into non-empty arrays of the specified size. * + * **Details** + * * The final array may be smaller if there are not enough elements to fill it. * - * @example + * **Example** (Grouping elements by size) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9772,16 +10911,19 @@ export declare const throttle: { * // Output: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ export declare const grouped: { /** * Partitions the stream into non-empty arrays of the specified size. * + * **Details** + * * The final array may be smaller if there are not enough elements to fill it. * - * @example + * **Example** (Grouping elements by size) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9797,16 +10939,19 @@ export declare const grouped: { * // Output: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (n: number): (self: Stream) => Stream, E, R>; /** * Partitions the stream into non-empty arrays of the specified size. * + * **Details** + * * The final array may be smaller if there are not enough elements to fill it. * - * @example + * **Example** (Grouping elements by size) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9822,8 +10967,8 @@ export declare const grouped: { * // Output: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (self: Stream, n: number): Stream, E, R>; }; @@ -9831,7 +10976,8 @@ export declare const grouped: { * Partitions the stream into arrays, emitting when the chunk size is reached * or the duration passes. * - * @example + * **Example** (Grouping elements by size or time) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9847,15 +10993,16 @@ export declare const grouped: { * // Output: [ [ 1, 2 ], [ 3 ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ export declare const groupedWithin: { /** * Partitions the stream into arrays, emitting when the chunk size is reached * or the duration passes. * - * @example + * **Example** (Grouping elements by size or time) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9871,15 +11018,16 @@ export declare const groupedWithin: { * // Output: [ [ 1, 2 ], [ 3 ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (chunkSize: number, duration: Duration.Input): (self: Stream) => Stream, E, R>; /** * Partitions the stream into arrays, emitting when the chunk size is reached * or the duration passes. * - * @example + * **Example** (Grouping elements by size or time) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9895,15 +11043,16 @@ export declare const groupedWithin: { * // Output: [ [ 1, 2 ], [ 3 ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (self: Stream, chunkSize: number, duration: Duration.Input): Stream, E, R>; }; /** * Groups elements into keyed substreams using an effectful classifier. * - * @example + * **Example** (Grouping elements into keyed substreams using an effectful classifier) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9928,14 +11077,15 @@ export declare const groupedWithin: { * // Output: [ [ "odd", [ 1, 3, 5 ] ], [ "even", [ 2, 4 ] ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ export declare const groupBy: { /** * Groups elements into keyed substreams using an effectful classifier. * - * @example + * **Example** (Grouping elements into keyed substreams using an effectful classifier) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9960,8 +11110,8 @@ export declare const groupBy: { * // Output: [ [ "odd", [ 1, 3, 5 ] ], [ "even", [ 2, 4 ] ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (f: (a: NoInfer) => Effect.Effect, options?: { readonly bufferSize?: number | undefined; @@ -9970,7 +11120,8 @@ export declare const groupBy: { /** * Groups elements into keyed substreams using an effectful classifier. * - * @example + * **Example** (Grouping elements into keyed substreams using an effectful classifier) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -9995,8 +11146,8 @@ export declare const groupBy: { * // Output: [ [ "odd", [ 1, 3, 5 ] ], [ "even", [ 2, 4 ] ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (self: Stream, f: (a: NoInfer) => Effect.Effect, options?: { readonly bufferSize?: number | undefined; @@ -10006,7 +11157,8 @@ export declare const groupBy: { /** * Groups elements by a key and emits a stream per key. * - * @example + * **Example** (Grouping elements by key) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10029,14 +11181,15 @@ export declare const groupBy: { * // Output: [ [ "odd", [ 1, 3, 5 ] ], [ "even", [ 2, 4 ] ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ export declare const groupByKey: { /** * Groups elements by a key and emits a stream per key. * - * @example + * **Example** (Grouping elements by key) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10059,8 +11212,8 @@ export declare const groupByKey: { * // Output: [ [ "odd", [ 1, 3, 5 ] ], [ "even", [ 2, 4 ] ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (f: (a: NoInfer) => K, options?: { readonly bufferSize?: number | undefined; @@ -10069,7 +11222,8 @@ export declare const groupByKey: { /** * Groups elements by a key and emits a stream per key. * - * @example + * **Example** (Grouping elements by key) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10092,8 +11246,8 @@ export declare const groupByKey: { * // Output: [ [ "odd", [ 1, 3, 5 ] ], [ "even", [ 2, 4 ] ] ] * ``` * + * @category grouping * @since 2.0.0 - * @category Grouping */ (self: Stream, f: (a: NoInfer) => K, options?: { readonly bufferSize?: number | undefined; @@ -10101,25 +11255,77 @@ export declare const groupByKey: { }): Stream], E, R>; }; /** + * Groups consecutive elements that have equal keys into non-empty arrays. + * + * **When to use** + * + * Use when you already have a stream ordered by the grouping key and want to + * emit each consecutive run as a non-empty array while keeping later + * non-adjacent runs separate. + * + * **Details** + * + * The key is computed with `f`; adjacent elements whose keys are equal by + * `Equal.equals` are emitted as one `[key, group]`. Later non-adjacent runs + * with the same key are emitted separately. + * + * @see {@link groupByKey} for grouping all elements with the same key across the stream + * @see {@link groupBy} for custom grouped stream construction + * + * @category grouping * @since 2.0.0 - * @category Grouping */ export declare const groupAdjacentBy: { /** + * Groups consecutive elements that have equal keys into non-empty arrays. + * + * **When to use** + * + * Use when you already have a stream ordered by the grouping key and want to + * emit each consecutive run as a non-empty array while keeping later + * non-adjacent runs separate. + * + * **Details** + * + * The key is computed with `f`; adjacent elements whose keys are equal by + * `Equal.equals` are emitted as one `[key, group]`. Later non-adjacent runs + * with the same key are emitted separately. + * + * @see {@link groupByKey} for grouping all elements with the same key across the stream + * @see {@link groupBy} for custom grouped stream construction + * + * @category grouping * @since 2.0.0 - * @category Grouping */ (f: (a: NoInfer) => K): (self: Stream) => Stream], E, R>; /** + * Groups consecutive elements that have equal keys into non-empty arrays. + * + * **When to use** + * + * Use when you already have a stream ordered by the grouping key and want to + * emit each consecutive run as a non-empty array while keeping later + * non-adjacent runs separate. + * + * **Details** + * + * The key is computed with `f`; adjacent elements whose keys are equal by + * `Equal.equals` are emitted as one `[key, group]`. Later non-adjacent runs + * with the same key are emitted separately. + * + * @see {@link groupByKey} for grouping all elements with the same key across the stream + * @see {@link groupBy} for custom grouped stream construction + * + * @category grouping * @since 2.0.0 - * @category Grouping */ (self: Stream, f: (a: NoInfer) => K): Stream], E, R>; }; /** * Applies a sink transducer to the stream and emits each sink result. * - * @example + * **Example** (Transducing with a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -10134,17 +11340,20 @@ export declare const groupAdjacentBy: { * }) * ``` * - * @since 2.0.0 * @category Aggregation + * @since 2.0.0 */ export declare const transduce: ((sink: Sink.Sink) => (self: Stream) => Stream) & ((self: Stream, sink: Sink.Sink) => Stream); /** * Aggregates elements using the provided sink and emits each sink result as a stream element. * + * **Details** + * * The stream runs the upstream and downstream in separate fibers, so the sink can keep * consuming input while downstream is busy processing the previous output. * - * @example + * **Example** (Aggregating with a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -10161,17 +11370,20 @@ export declare const transduce: ((sink: Sink.Sink(sink: Sink.Sink): (self: Stream) => Stream; /** * Aggregates elements using the provided sink and emits each sink result as a stream element. * + * **Details** + * * The stream runs the upstream and downstream in separate fibers, so the sink can keep * consuming input while downstream is busy processing the previous output. * - * @example + * **Example** (Aggregating with a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -10215,17 +11430,20 @@ export declare const aggregate: { * // [ 6, 15 ] * ``` * - * @since 2.0.0 * @category Aggregation + * @since 2.0.0 */ (self: Stream, sink: Sink.Sink): Stream; }; /** * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers. * + * **Details** + * * The schedule can flush the current aggregation even if the sink has not finished. * - * @example + * **Example** (Aggregating with a sink and schedule) + * * ```ts * import { Console, Effect, Schedule, Sink, Stream } from "effect" * @@ -10243,16 +11461,19 @@ export declare const aggregate: { * // Output: [ 6, 15 ] * ``` * - * @since 2.0.0 * @category Aggregation + * @since 2.0.0 */ export declare const aggregateWithin: { /** * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers. * + * **Details** + * * The schedule can flush the current aggregation even if the sink has not finished. * - * @example + * **Example** (Aggregating with a sink and schedule) + * * ```ts * import { Console, Effect, Schedule, Sink, Stream } from "effect" * @@ -10270,16 +11491,19 @@ export declare const aggregateWithin: { * // Output: [ 6, 15 ] * ``` * - * @since 2.0.0 * @category Aggregation + * @since 2.0.0 */ (sink: Sink.Sink, schedule: Schedule.Schedule, E3, R3>): (self: Stream) => Stream; /** * Aggregates elements with a sink, emitting each result when the sink completes or the schedule triggers. * + * **Details** + * * The schedule can flush the current aggregation even if the sink has not finished. * - * @example + * **Example** (Aggregating with a sink and schedule) + * * ```ts * import { Console, Effect, Schedule, Sink, Stream } from "effect" * @@ -10297,17 +11521,159 @@ export declare const aggregateWithin: { * // Output: [ 6, 15 ] * ``` * - * @since 2.0.0 * @category Aggregation + * @since 2.0.0 */ (self: Stream, sink: Sink.Sink, schedule: Schedule.Schedule, E3, R3>): Stream; }; +/** + * Creates a fixed-size tuple of streams that each emit + * the same elements as the source stream. + * + * **Details** + * + * The source stream starts after all downstream streams have been subscribed. + * With the default suspend strategy, the source can only advance `capacity` + * chunks ahead of the slowest downstream stream. If a downstream stream is + * interrupted, it unsubscribes from the broadcast so it no longer contributes + * backpressure. + * + * **Example** (Broadcasting to two consumers) + * + * ```ts + * import { Console, Effect, Stream } from "effect" + * + * const program = Effect.scoped( + * Effect.gen(function*() { + * const [left, right] = yield* Stream.make(1, 2, 3).pipe( + * Stream.broadcastN({ n: 2, capacity: 8 }) + * ) + * + * const values = yield* Effect.all([ + * Stream.runCollect(left), + * Stream.runCollect(right) + * ], { concurrency: "unbounded" }) + * + * yield* Console.log(values) + * }) + * ) + * + * Effect.runPromise(program) + * // Output: [[1, 2, 3], [1, 2, 3]] + * ``` + * + * @category Broadcast + * @since 4.0.0 + */ +export declare const broadcastN: { + /** + * Creates a fixed-size tuple of streams that each emit + * the same elements as the source stream. + * + * **Details** + * + * The source stream starts after all downstream streams have been subscribed. + * With the default suspend strategy, the source can only advance `capacity` + * chunks ahead of the slowest downstream stream. If a downstream stream is + * interrupted, it unsubscribes from the broadcast so it no longer contributes + * backpressure. + * + * **Example** (Broadcasting to two consumers) + * + * ```ts + * import { Console, Effect, Stream } from "effect" + * + * const program = Effect.scoped( + * Effect.gen(function*() { + * const [left, right] = yield* Stream.make(1, 2, 3).pipe( + * Stream.broadcastN({ n: 2, capacity: 8 }) + * ) + * + * const values = yield* Effect.all([ + * Stream.runCollect(left), + * Stream.runCollect(right) + * ], { concurrency: "unbounded" }) + * + * yield* Console.log(values) + * }) + * ) + * + * Effect.runPromise(program) + * // Output: [[1, 2, 3], [1, 2, 3]] + * ``` + * + * @category Broadcast + * @since 4.0.0 + */ + (options: { + readonly n: N; + readonly capacity: "unbounded"; + readonly replay?: number | undefined; + } | { + readonly n: N; + readonly capacity: number; + readonly strategy?: "sliding" | "dropping" | "suspend" | undefined; + readonly replay?: number | undefined; + }): (self: Stream) => Effect.Effect>, never, Scope.Scope | R>; + /** + * Creates a fixed-size tuple of streams that each emit + * the same elements as the source stream. + * + * **Details** + * + * The source stream starts after all downstream streams have been subscribed. + * With the default suspend strategy, the source can only advance `capacity` + * chunks ahead of the slowest downstream stream. If a downstream stream is + * interrupted, it unsubscribes from the broadcast so it no longer contributes + * backpressure. + * + * **Example** (Broadcasting to two consumers) + * + * ```ts + * import { Console, Effect, Stream } from "effect" + * + * const program = Effect.scoped( + * Effect.gen(function*() { + * const [left, right] = yield* Stream.make(1, 2, 3).pipe( + * Stream.broadcastN({ n: 2, capacity: 8 }) + * ) + * + * const values = yield* Effect.all([ + * Stream.runCollect(left), + * Stream.runCollect(right) + * ], { concurrency: "unbounded" }) + * + * yield* Console.log(values) + * }) + * ) + * + * Effect.runPromise(program) + * // Output: [[1, 2, 3], [1, 2, 3]] + * ``` + * + * @category Broadcast + * @since 4.0.0 + */ + (self: Stream, options: { + readonly n: N; + readonly capacity: "unbounded"; + readonly replay?: number | undefined; + } | { + readonly capacity: number; + readonly n: N; + readonly strategy?: "sliding" | "dropping" | "suspend" | undefined; + readonly replay?: number | undefined; + }): Effect.Effect>, never, Scope.Scope | R>; +}; /** * Creates a PubSub-backed stream that multicasts the source to all subscribers. * + * **Details** + * * The returned stream is scoped and uses the provided PubSub capacity and replay settings. * - * @example + * **Example** (Broadcasting a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10331,16 +11697,19 @@ export declare const aggregateWithin: { * // Output: [[1, 2, 3], [1, 2, 3]] * ``` * - * @since 2.0.0 * @category Broadcast + * @since 2.0.0 */ export declare const broadcast: { /** * Creates a PubSub-backed stream that multicasts the source to all subscribers. * + * **Details** + * * The returned stream is scoped and uses the provided PubSub capacity and replay settings. * - * @example + * **Example** (Broadcasting a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10364,8 +11733,8 @@ export declare const broadcast: { * // Output: [[1, 2, 3], [1, 2, 3]] * ``` * - * @since 2.0.0 * @category Broadcast + * @since 2.0.0 */ (options: { readonly capacity: "unbounded"; @@ -10378,9 +11747,12 @@ export declare const broadcast: { /** * Creates a PubSub-backed stream that multicasts the source to all subscribers. * + * **Details** + * * The returned stream is scoped and uses the provided PubSub capacity and replay settings. * - * @example + * **Example** (Broadcasting a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10404,8 +11776,8 @@ export declare const broadcast: { * // Output: [[1, 2, 3], [1, 2, 3]] * ``` * - * @since 2.0.0 * @category Broadcast + * @since 2.0.0 */ (self: Stream, options: { readonly capacity: "unbounded"; @@ -10419,11 +11791,14 @@ export declare const broadcast: { /** * Returns a new Stream that multicasts the original stream, subscribing when the first consumer starts. * + * **Details** + * * The upstream continues running while there is at least one consumer and is finalized after the last one exits. * If `idleTimeToLive` is set, the upstream is kept alive for that duration so a later subscriber can continue from * the next element instead of restarting. * - * @example + * **Example** (Sharing a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10444,18 +11819,21 @@ export declare const broadcast: { * // output: [[1], [1]] * ``` * - * @since 2.0.0 * @category Broadcast + * @since 3.8.0 */ export declare const share: { /** * Returns a new Stream that multicasts the original stream, subscribing when the first consumer starts. * + * **Details** + * * The upstream continues running while there is at least one consumer and is finalized after the last one exits. * If `idleTimeToLive` is set, the upstream is kept alive for that duration so a later subscriber can continue from * the next element instead of restarting. * - * @example + * **Example** (Sharing a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10476,8 +11854,8 @@ export declare const share: { * // output: [[1], [1]] * ``` * - * @since 2.0.0 * @category Broadcast + * @since 3.8.0 */ (options: { readonly capacity: "unbounded"; @@ -10492,11 +11870,14 @@ export declare const share: { /** * Returns a new Stream that multicasts the original stream, subscribing when the first consumer starts. * + * **Details** + * * The upstream continues running while there is at least one consumer and is finalized after the last one exits. * If `idleTimeToLive` is set, the upstream is kept alive for that duration so a later subscriber can continue from * the next element instead of restarting. * - * @example + * **Example** (Sharing a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10517,8 +11898,8 @@ export declare const share: { * // output: [[1], [1]] * ``` * - * @since 2.0.0 * @category Broadcast + * @since 3.8.0 */ (self: Stream, options: { readonly capacity: "unbounded"; @@ -10534,10 +11915,13 @@ export declare const share: { /** * Pipes this stream through a channel that consumes and emits chunked elements. * + * **Details** + * * The channel receives `NonEmptyReadonlyArray` chunks and can transform both the * output elements and error type. * - * @example + * **Example** (Piping through a channel) + * * ```ts * import { Array, Channel, Console, Effect, Stream } from "effect" * @@ -10560,17 +11944,20 @@ export declare const share: { * // => [2, 4, 6] * ``` * - * @since 2.0.0 * @category Pipe + * @since 2.0.0 */ export declare const pipeThroughChannel: { /** * Pipes this stream through a channel that consumes and emits chunked elements. * + * **Details** + * * The channel receives `NonEmptyReadonlyArray` chunks and can transform both the * output elements and error type. * - * @example + * **Example** (Piping through a channel) + * * ```ts * import { Array, Channel, Console, Effect, Stream } from "effect" * @@ -10593,17 +11980,20 @@ export declare const pipeThroughChannel: { * // => [2, 4, 6] * ``` * - * @since 2.0.0 * @category Pipe + * @since 2.0.0 */ (channel: Channel.Channel, E2, unknown, Arr.NonEmptyReadonlyArray, E, unknown, R2>): (self: Stream) => Stream; /** * Pipes this stream through a channel that consumes and emits chunked elements. * + * **Details** + * * The channel receives `NonEmptyReadonlyArray` chunks and can transform both the * output elements and error type. * - * @example + * **Example** (Piping through a channel) + * * ```ts * import { Array, Channel, Console, Effect, Stream } from "effect" * @@ -10626,8 +12016,8 @@ export declare const pipeThroughChannel: { * // => [2, 4, 6] * ``` * - * @since 2.0.0 * @category Pipe + * @since 2.0.0 */ (self: Stream, channel: Channel.Channel, E2, unknown, Arr.NonEmptyReadonlyArray, E, unknown, R2>): Stream; }; @@ -10635,123 +12025,120 @@ export declare const pipeThroughChannel: { * Pipes values through the provided channel while preserving this stream's * failures alongside any channel failures. * + * **Details** + * * Upstream failures are not passed to the channel, so the resulting stream can * fail with either the original stream error or the channel error. * - * @example + * **Example** (Piping through a channel with failures) + * * ```ts - * import type { Channel } from "effect" - * import { Console, Effect, Stream } from "effect" + * import { Array, Channel, Effect, Stream } from "effect" * - * declare const transformChannel: Channel.Channel< - * readonly [string, ...Array], - * "ChannelError", - * unknown, - * readonly [number, ...Array], - * "StreamError", - * unknown, - * never - * > + * type NumberChunk = readonly [number, ...Array] + * + * const stringifyChunks = Channel.identity().pipe( + * Channel.map((chunk) => Array.map(chunk, String)) + * ) * * Effect.runPromise(Effect.gen(function*() { * const result = yield* Stream.make(1, 2, 3).pipe( - * Stream.pipeThroughChannelOrFail(transformChannel), + * Stream.rechunk(2), + * Stream.pipeThroughChannelOrFail(stringifyChunks), * Stream.runCollect * ) * - * yield* Console.log(result) + * yield* Effect.sync(() => console.log(result)) * })) - * // Output: - * // ["1", "2", "3"] + * // [ "1", "2", "3" ] * ``` * - * @since 2.0.0 * @category Pipe + * @since 2.0.0 */ export declare const pipeThroughChannelOrFail: { /** * Pipes values through the provided channel while preserving this stream's * failures alongside any channel failures. * + * **Details** + * * Upstream failures are not passed to the channel, so the resulting stream can * fail with either the original stream error or the channel error. * - * @example + * **Example** (Piping through a channel with failures) + * * ```ts - * import type { Channel } from "effect" - * import { Console, Effect, Stream } from "effect" + * import { Array, Channel, Effect, Stream } from "effect" + * + * type NumberChunk = readonly [number, ...Array] * - * declare const transformChannel: Channel.Channel< - * readonly [string, ...Array], - * "ChannelError", - * unknown, - * readonly [number, ...Array], - * "StreamError", - * unknown, - * never - * > + * const stringifyChunks = Channel.identity().pipe( + * Channel.map((chunk) => Array.map(chunk, String)) + * ) * * Effect.runPromise(Effect.gen(function*() { * const result = yield* Stream.make(1, 2, 3).pipe( - * Stream.pipeThroughChannelOrFail(transformChannel), + * Stream.rechunk(2), + * Stream.pipeThroughChannelOrFail(stringifyChunks), * Stream.runCollect * ) * - * yield* Console.log(result) + * yield* Effect.sync(() => console.log(result)) * })) - * // Output: - * // ["1", "2", "3"] + * // [ "1", "2", "3" ] * ``` * - * @since 2.0.0 * @category Pipe + * @since 2.0.0 */ (channel: Channel.Channel, E2, unknown, Arr.NonEmptyReadonlyArray, E, unknown, R2>): (self: Stream) => Stream; /** * Pipes values through the provided channel while preserving this stream's * failures alongside any channel failures. * + * **Details** + * * Upstream failures are not passed to the channel, so the resulting stream can * fail with either the original stream error or the channel error. * - * @example + * **Example** (Piping through a channel with failures) + * * ```ts - * import type { Channel } from "effect" - * import { Console, Effect, Stream } from "effect" + * import { Array, Channel, Effect, Stream } from "effect" + * + * type NumberChunk = readonly [number, ...Array] * - * declare const transformChannel: Channel.Channel< - * readonly [string, ...Array], - * "ChannelError", - * unknown, - * readonly [number, ...Array], - * "StreamError", - * unknown, - * never - * > + * const stringifyChunks = Channel.identity().pipe( + * Channel.map((chunk) => Array.map(chunk, String)) + * ) * * Effect.runPromise(Effect.gen(function*() { * const result = yield* Stream.make(1, 2, 3).pipe( - * Stream.pipeThroughChannelOrFail(transformChannel), + * Stream.rechunk(2), + * Stream.pipeThroughChannelOrFail(stringifyChunks), * Stream.runCollect * ) * - * yield* Console.log(result) + * yield* Effect.sync(() => console.log(result)) * })) - * // Output: - * // ["1", "2", "3"] + * // [ "1", "2", "3" ] * ``` * - * @since 2.0.0 * @category Pipe + * @since 2.0.0 */ (self: Stream, channel: Channel.Channel, E2, unknown, Arr.NonEmptyReadonlyArray, E, unknown, R2>): Stream; }; /** * Pipes the stream through `Sink.toChannel`, emitting only the sink leftovers. * + * **Details** + * * If the sink completes mid-chunk, the remaining elements become the output stream. * - * @example + * **Example** (Piping through a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -10768,16 +12155,19 @@ export declare const pipeThroughChannelOrFail: { * //=> [ 3, 4 ] * ``` * - * @since 2.0.0 * @category Pipe + * @since 2.0.0 */ export declare const pipeThrough: { /** * Pipes the stream through `Sink.toChannel`, emitting only the sink leftovers. * + * **Details** + * * If the sink completes mid-chunk, the remaining elements become the output stream. * - * @example + * **Example** (Piping through a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -10794,16 +12184,19 @@ export declare const pipeThrough: { * //=> [ 3, 4 ] * ``` * - * @since 2.0.0 * @category Pipe + * @since 2.0.0 */ (sink: Sink.Sink): (self: Stream) => Stream; /** * Pipes the stream through `Sink.toChannel`, emitting only the sink leftovers. * + * **Details** + * * If the sink completes mid-chunk, the remaining elements become the output stream. * - * @example + * **Example** (Piping through a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -10820,15 +12213,16 @@ export declare const pipeThrough: { * //=> [ 3, 4 ] * ``` * - * @since 2.0.0 * @category Pipe + * @since 2.0.0 */ (self: Stream, sink: Sink.Sink): Stream; }; /** * Collects all elements into an array and emits it as a single element. * - * @example + * **Example** (Collecting values into a stream element) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10843,14 +12237,15 @@ export declare const pipeThrough: { * // [1, 2, 3] * ``` * - * @since 2.0.0 * @category Accumulation + * @since 4.0.0 */ export declare const collect: (self: Stream) => Stream, E, R>; /** * Accumulates elements into a growing array, emitting the cumulative array for each input chunk. * - * @example + * **Example** (Accumulating stream elements) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10868,14 +12263,15 @@ export declare const collect: (self: Stream) => Stream { _id: 'Chunk', values: [ [ 1 ], [ 1, 2 ], [ 1, 2, 3 ] ] } * ``` * - * @since 2.0.0 * @category Accumulation + * @since 2.0.0 */ export declare const accumulate: (self: Stream) => Stream, E, R>; /** * Emits only elements that differ from the previous one. * - * @example + * **Example** (Emitting changed values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10892,14 +12288,15 @@ export declare const accumulate: (self: Stream) => Stream(self: Stream) => Stream; /** * Returns a stream that only emits elements that are not equal to the previously emitted element, as determined by the specified predicate. * - * @example + * **Example** (Emitting values that changed by equivalence) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10916,14 +12313,15 @@ export declare const changes: (self: Stream) => Stream(f: (x: A, y: A) => boolean): (self: Stream) => Stream; /** * Returns a stream that only emits elements that are not equal to the previously emitted element, as determined by the specified predicate. * - * @example + * **Example** (Emitting values that changed by equivalence) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10964,17 +12363,20 @@ export declare const changesWith: { * // ["A", "B"] * ``` * - * @since 2.0.0 * @category Deduplication + * @since 2.0.0 */ (self: Stream, f: (x: A, y: A) => boolean): Stream; }; /** * Emits only elements that differ from the previous element, using an effectful equality check. * + * **Details** + * * The predicate runs for each element after the first; returning `true` treats it as equal and skips it. * - * @example + * **Example** (Effectfully emitting changed values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -10990,16 +12392,19 @@ export declare const changesWith: { * // { _id: "Chunk", values: [ 1, 2, 3 ] } * ``` * - * @since 2.0.0 * @category Deduplication + * @since 2.0.0 */ export declare const changesWithEffect: { /** * Emits only elements that differ from the previous element, using an effectful equality check. * + * **Details** + * * The predicate runs for each element after the first; returning `true` treats it as equal and skips it. * - * @example + * **Example** (Effectfully emitting changed values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11015,16 +12420,19 @@ export declare const changesWithEffect: { * // { _id: "Chunk", values: [ 1, 2, 3 ] } * ``` * - * @since 2.0.0 * @category Deduplication + * @since 2.0.0 */ (f: (x: A, y: A) => Effect.Effect): (self: Stream) => Stream; /** * Emits only elements that differ from the previous element, using an effectful equality check. * + * **Details** + * * The predicate runs for each element after the first; returning `true` treats it as equal and skips it. * - * @example + * **Example** (Effectfully emitting changed values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11040,15 +12448,16 @@ export declare const changesWithEffect: { * // { _id: "Chunk", values: [ 1, 2, 3 ] } * ``` * - * @since 2.0.0 * @category Deduplication + * @since 2.0.0 */ (self: Stream, f: (x: A, y: A) => Effect.Effect): Stream; }; /** * Decodes Uint8Array chunks into strings using TextDecoder with an optional encoding. * - * @example + * **Example** (Decoding Uint8Array chunks into strings using TextDecoder with an optional encoding) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11070,8 +12479,8 @@ export declare const changesWithEffect: { * // ["Hello", " World"] * ``` * + * @category encoding * @since 2.0.0 - * @category Encoding */ export declare const decodeText: | { readonly encoding?: string | undefined; @@ -11083,7 +12492,8 @@ export declare const decodeText: | { /** * Encodes a stream of strings into UTF-8 `Uint8Array` chunks. * - * @example + * **Example** (Encoding a stream of strings into UTF-8 Uint8Array chunks) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11099,14 +12509,15 @@ export declare const decodeText: | { * // [[72, 101, 108, 108, 111], [32], [87, 111, 114, 108, 100]] * ``` * + * @category encoding * @since 2.0.0 - * @category Encoding */ export declare const encodeText: (self: Stream) => Stream; /** * Splits a stream of strings into lines, handling `\n`, `\r`, and `\r\n` delimiters across chunks. * - * @example + * **Example** (Splitting streamed text into lines) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11119,14 +12530,15 @@ export declare const encodeText: (self: Stream) => Stream(self: Stream) => Stream; /** * Inserts the provided element between emitted elements. * - * @example + * **Example** (Interspersing stream elements) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11140,14 +12552,15 @@ export declare const splitLines: (self: Stream) => Stream(element: A2): (self: Stream) => Stream; /** * Inserts the provided element between emitted elements. * - * @example + * **Example** (Interspersing stream elements) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11182,17 +12596,20 @@ export declare const intersperse: { * // [1, 0, 2, 0, 3, 0, 4] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (self: Stream, element: A2): Stream; }; /** - * Intersperse stream elements with a middle value, adding a start and end value. + * Adds a start value, middle value, and end value around stream elements. + * + * **Details** * * The start and end values are always emitted, even when the stream is empty. * - * @example + * **Example** (Interspersing stream affixes) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11209,16 +12626,19 @@ export declare const intersperse: { * // [ "[", "a", ",", "b", ",", "c", "]" ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ export declare const intersperseAffixes: { /** - * Intersperse stream elements with a middle value, adding a start and end value. + * Adds a start value, middle value, and end value around stream elements. + * + * **Details** * * The start and end values are always emitted, even when the stream is empty. * - * @example + * **Example** (Interspersing stream affixes) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11235,8 +12655,8 @@ export declare const intersperseAffixes: { * // [ "[", "a", ",", "b", ",", "c", "]" ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (options: { readonly start: A2; @@ -11244,11 +12664,14 @@ export declare const intersperseAffixes: { readonly end: A4; }): (self: Stream) => Stream; /** - * Intersperse stream elements with a middle value, adding a start and end value. + * Adds a start value, middle value, and end value around stream elements. + * + * **Details** * * The start and end values are always emitted, even when the stream is empty. * - * @example + * **Example** (Interspersing stream affixes) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11265,8 +12688,8 @@ export declare const intersperseAffixes: { * // [ "[", "a", ",", "b", ",", "c", "]" ] * ``` * + * @category sequencing * @since 2.0.0 - * @category Sequencing */ (self: Stream, options: { readonly start: A2; @@ -11279,7 +12702,8 @@ export declare const intersperseAffixes: { * each stream; when one ends, the remaining values from the other stream are * emitted. * - * @example + * **Example** (Interleaving streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11296,8 +12720,9 @@ export declare const intersperseAffixes: { * Effect.runPromise(program) * // [2, 5, 3, 6, 7] * ``` + * + * @category merging * @since 2.0.0 - * @category Merging */ export declare const interleave: { /** @@ -11305,7 +12730,8 @@ export declare const interleave: { * each stream; when one ends, the remaining values from the other stream are * emitted. * - * @example + * **Example** (Interleaving streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11322,8 +12748,9 @@ export declare const interleave: { * Effect.runPromise(program) * // [2, 5, 3, 6, 7] * ``` + * + * @category merging * @since 2.0.0 - * @category Merging */ (that: Stream): (self: Stream) => Stream; /** @@ -11331,7 +12758,8 @@ export declare const interleave: { * each stream; when one ends, the remaining values from the other stream are * emitted. * - * @example + * **Example** (Interleaving streams) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11348,18 +12776,22 @@ export declare const interleave: { * Effect.runPromise(program) * // [2, 5, 3, 6, 7] * ``` + * + * @category merging * @since 2.0.0 - * @category Merging */ (self: Stream, that: Stream): Stream; }; /** * Interleaves two streams deterministically by following a boolean decider stream. * + * **Details** + * * The decider controls how many elements are pulled; if one side ends, pulls for * that side are ignored. * - * @example + * **Example** (Interleaving two streams deterministically by following a boolean decider stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11379,17 +12811,20 @@ export declare const interleave: { * // [ 1, 2, 4, 3, 5 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ export declare const interleaveWith: { /** * Interleaves two streams deterministically by following a boolean decider stream. * + * **Details** + * * The decider controls how many elements are pulled; if one side ends, pulls for * that side are ignored. * - * @example + * **Example** (Interleaving two streams deterministically by following a boolean decider stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11409,17 +12844,20 @@ export declare const interleaveWith: { * // [ 1, 2, 4, 3, 5 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ (that: Stream, decider: Stream): (self: Stream) => Stream; /** * Interleaves two streams deterministically by following a boolean decider stream. * + * **Details** + * * The decider controls how many elements are pulled; if one side ends, pulls for * that side are ignored. * - * @example + * **Example** (Interleaving two streams deterministically by following a boolean decider stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11439,8 +12877,8 @@ export declare const interleaveWith: { * // [ 1, 2, 4, 3, 5 ] * ``` * + * @category merging * @since 2.0.0 - * @category Merging */ (self: Stream, that: Stream, decider: Stream): Stream; }; @@ -11450,10 +12888,13 @@ export declare const interleaveWith: { * success will be discarded. This combinator will also interrupt any * in-progress element being pulled from upstream. * + * **Details** + * * If the effect completes with a failure before the stream completes, the * returned stream will emit that failure. * - * @example + * **Example** (Interrupting when an effect completes) + * * ```ts * import { Console, Deferred, Effect, Stream } from "effect" * @@ -11476,8 +12917,8 @@ export declare const interleaveWith: { * // => [1, 2] * ``` * + * @category interruption * @since 2.0.0 - * @category Interruption */ export declare const interruptWhen: { /** @@ -11486,10 +12927,13 @@ export declare const interruptWhen: { * success will be discarded. This combinator will also interrupt any * in-progress element being pulled from upstream. * + * **Details** + * * If the effect completes with a failure before the stream completes, the * returned stream will emit that failure. * - * @example + * **Example** (Interrupting when an effect completes) + * * ```ts * import { Console, Deferred, Effect, Stream } from "effect" * @@ -11512,8 +12956,8 @@ export declare const interruptWhen: { * // => [1, 2] * ``` * + * @category interruption * @since 2.0.0 - * @category Interruption */ (effect: Effect.Effect): (self: Stream) => Stream; /** @@ -11522,10 +12966,13 @@ export declare const interruptWhen: { * success will be discarded. This combinator will also interrupt any * in-progress element being pulled from upstream. * + * **Details** + * * If the effect completes with a failure before the stream completes, the * returned stream will emit that failure. * - * @example + * **Example** (Interrupting when an effect completes) + * * ```ts * import { Console, Deferred, Effect, Stream } from "effect" * @@ -11548,15 +12995,30 @@ export declare const interruptWhen: { * // => [1, 2] * ``` * + * @category interruption * @since 2.0.0 - * @category Interruption */ (self: Stream, effect: Effect.Effect): Stream; }; /** - * Halts evaluation after the current element once the provided effect completes; the effect is forked, its success is discarded, failures fail the stream, and it does not interrupt an in-progress pull (use `interruptWhen` for that). + * Stops a stream after the current element when an effect completes. + * + * **When to use** + * + * Use to stop before the next pull after an external signal completes. + * + * **Details** + * + * The effect is forked, its success value is discarded, and its failure fails + * the stream. + * + * **Gotchas** + * + * This does not interrupt an in-progress pull. Use {@link interruptWhen} when + * the stream should be interrupted immediately. + * + * **Example** (Halting a stream after an effect completes) * - * @example * ```ts * import { Console, Deferred, Effect, Stream } from "effect" * @@ -11575,14 +13037,29 @@ export declare const interruptWhen: { * // [1, 2] * ``` * + * @category interruption * @since 2.0.0 - * @category Interruption */ export declare const haltWhen: { /** - * Halts evaluation after the current element once the provided effect completes; the effect is forked, its success is discarded, failures fail the stream, and it does not interrupt an in-progress pull (use `interruptWhen` for that). + * Stops a stream after the current element when an effect completes. + * + * **When to use** + * + * Use to stop before the next pull after an external signal completes. + * + * **Details** + * + * The effect is forked, its success value is discarded, and its failure fails + * the stream. + * + * **Gotchas** + * + * This does not interrupt an in-progress pull. Use {@link interruptWhen} when + * the stream should be interrupted immediately. + * + * **Example** (Halting a stream after an effect completes) * - * @example * ```ts * import { Console, Deferred, Effect, Stream } from "effect" * @@ -11601,14 +13078,29 @@ export declare const haltWhen: { * // [1, 2] * ``` * + * @category interruption * @since 2.0.0 - * @category Interruption */ (effect: Effect.Effect): (self: Stream) => Stream; /** - * Halts evaluation after the current element once the provided effect completes; the effect is forked, its success is discarded, failures fail the stream, and it does not interrupt an in-progress pull (use `interruptWhen` for that). + * Stops a stream after the current element when an effect completes. + * + * **When to use** + * + * Use to stop before the next pull after an external signal completes. + * + * **Details** + * + * The effect is forked, its success value is discarded, and its failure fails + * the stream. + * + * **Gotchas** + * + * This does not interrupt an in-progress pull. Use {@link interruptWhen} when + * the stream should be interrupted immediately. + * + * **Example** (Halting a stream after an effect completes) * - * @example * ```ts * import { Console, Deferred, Effect, Stream } from "effect" * @@ -11627,15 +13119,16 @@ export declare const haltWhen: { * // [1, 2] * ``` * + * @category interruption * @since 2.0.0 - * @category Interruption */ (self: Stream, effect: Effect.Effect): Stream; }; /** * Runs the provided finalizer when the stream exits, passing the exit value. * - * @example + * **Example** (Running a finalizer on exit) + * * ```ts * import { Console, Effect, Exit, Stream } from "effect" * @@ -11654,14 +13147,15 @@ export declare const haltWhen: { * // Stream completed successfully * ``` * - * @since 4.0.0 * @category Finalization + * @since 4.0.0 */ export declare const onExit: { /** * Runs the provided finalizer when the stream exits, passing the exit value. * - * @example + * **Example** (Running a finalizer on exit) + * * ```ts * import { Console, Effect, Exit, Stream } from "effect" * @@ -11680,14 +13174,15 @@ export declare const onExit: { * // Stream completed successfully * ``` * - * @since 4.0.0 * @category Finalization + * @since 4.0.0 */ (finalizer: (exit: Exit.Exit) => Effect.Effect): (self: Stream) => Stream; /** * Runs the provided finalizer when the stream exits, passing the exit value. * - * @example + * **Example** (Running a finalizer on exit) + * * ```ts * import { Console, Effect, Exit, Stream } from "effect" * @@ -11706,18 +13201,21 @@ export declare const onExit: { * // Stream completed successfully * ``` * - * @since 4.0.0 * @category Finalization + * @since 4.0.0 */ (self: Stream, finalizer: (exit: Exit.Exit) => Effect.Effect): Stream; }; /** * Runs the provided effect when the stream fails, passing the failure cause. * + * **Gotchas** + * * Note: Unlike `Effect.onError` there is no guarantee that the provided * effect will not be interrupted. * - * @example + * **Example** (Running an effect on errors) + * * ```ts * import { Cause, Console, Effect, Stream } from "effect" * @@ -11735,17 +13233,20 @@ export declare const onExit: { * // Stream failed: boom * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ export declare const onError: { /** * Runs the provided effect when the stream fails, passing the failure cause. * + * **Gotchas** + * * Note: Unlike `Effect.onError` there is no guarantee that the provided * effect will not be interrupted. * - * @example + * **Example** (Running an effect on errors) + * * ```ts * import { Cause, Console, Effect, Stream } from "effect" * @@ -11763,17 +13264,20 @@ export declare const onError: { * // Stream failed: boom * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ (cleanup: (cause: Cause.Cause) => Effect.Effect): (self: Stream) => Stream; /** * Runs the provided effect when the stream fails, passing the failure cause. * + * **Gotchas** + * * Note: Unlike `Effect.onError` there is no guarantee that the provided * effect will not be interrupted. * - * @example + * **Example** (Running an effect on errors) + * * ```ts * import { Cause, Console, Effect, Stream } from "effect" * @@ -11791,15 +13295,16 @@ export declare const onError: { * // Stream failed: boom * ``` * + * @category error handling * @since 2.0.0 - * @category Error Handling */ (self: Stream, cleanup: (cause: Cause.Cause) => Effect.Effect): Stream; }; /** * Runs the provided effect before this stream starts. * - * @example + * **Example** (Running an effect on start) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11818,14 +13323,15 @@ export declare const onError: { * // [1, 2, 3] * ``` * - * @since 4.0.0 - * @category Sequencing + * @category sequencing + * @since 3.6.0 */ export declare const onStart: { /** * Runs the provided effect before this stream starts. * - * @example + * **Example** (Running an effect on start) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11844,14 +13350,15 @@ export declare const onStart: { * // [1, 2, 3] * ``` * - * @since 4.0.0 - * @category Sequencing + * @category sequencing + * @since 3.6.0 */ (onStart: Effect.Effect): (self: Stream) => Stream; /** * Runs the provided effect before this stream starts. * - * @example + * **Example** (Running an effect on start) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11870,15 +13377,16 @@ export declare const onStart: { * // [1, 2, 3] * ``` * - * @since 4.0.0 - * @category Sequencing + * @category sequencing + * @since 3.6.0 */ (self: Stream, onStart: Effect.Effect): Stream; }; /** * Runs the provided effect with the first element emitted by the stream. * - * @example + * **Example** (Running an effect on the first value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11891,14 +13399,15 @@ export declare const onStart: { * // Output: first=1 * ``` * + * @category sequencing * @since 4.0.0 - * @category Sequencing */ export declare const onFirst: { /** * Runs the provided effect with the first element emitted by the stream. * - * @example + * **Example** (Running an effect on the first value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11911,14 +13420,15 @@ export declare const onFirst: { * // Output: first=1 * ``` * + * @category sequencing * @since 4.0.0 - * @category Sequencing */ (onFirst: (element: NoInfer) => Effect.Effect): (self: Stream) => Stream; /** * Runs the provided effect with the first element emitted by the stream. * - * @example + * **Example** (Running an effect on the first value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11931,15 +13441,16 @@ export declare const onFirst: { * // Output: first=1 * ``` * + * @category sequencing * @since 4.0.0 - * @category Sequencing */ (self: Stream, onFirst: (element: NoInfer) => Effect.Effect): Stream; }; /** * Runs the provided effect when the stream ends successfully. * - * @example + * **Example** (Running an effect on end) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11956,14 +13467,15 @@ export declare const onFirst: { * // [1, 2, 3] * ``` * - * @since 4.0.0 - * @category Sequencing + * @category sequencing + * @since 3.6.0 */ export declare const onEnd: { /** * Runs the provided effect when the stream ends successfully. * - * @example + * **Example** (Running an effect on end) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -11980,14 +13492,15 @@ export declare const onEnd: { * // [1, 2, 3] * ``` * - * @since 4.0.0 - * @category Sequencing + * @category sequencing + * @since 3.6.0 */ (onEnd: Effect.Effect): (self: Stream) => Stream; /** * Runs the provided effect when the stream ends successfully. * - * @example + * **Example** (Running an effect on end) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12004,15 +13517,16 @@ export declare const onEnd: { * // [1, 2, 3] * ``` * - * @since 4.0.0 - * @category Sequencing + * @category sequencing + * @since 3.6.0 */ (self: Stream, onEnd: Effect.Effect): Stream; }; /** * Executes the provided finalizer after this stream's finalizers run. * - * @example + * **Example** (Ensuring finalization) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12030,14 +13544,15 @@ export declare const onEnd: { * //=> [1, 2] * ``` * - * @since 4.0.0 * @category Finalization + * @since 2.0.0 */ export declare const ensuring: { /** * Executes the provided finalizer after this stream's finalizers run. * - * @example + * **Example** (Ensuring finalization) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12055,14 +13570,15 @@ export declare const ensuring: { * //=> [1, 2] * ``` * - * @since 4.0.0 * @category Finalization + * @since 2.0.0 */ (finalizer: Effect.Effect): (self: Stream) => Stream; /** * Executes the provided finalizer after this stream's finalizers run. * - * @example + * **Example** (Ensuring finalization) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12080,8 +13596,8 @@ export declare const ensuring: { * //=> [1, 2] * ``` * - * @since 4.0.0 * @category Finalization + * @since 2.0.0 */ (self: Stream, finalizer: Effect.Effect): Stream; }; @@ -12090,11 +13606,10 @@ export declare const ensuring: { * service requirements. Use `options.local` to build the layer every time; by * default, layers are shared between provide calls. * - * **Previously Known As:** `provideSomeLayer`, `provideSomeContext`. + * **Example** (Providing stream requirements) * - * @example * ```ts - * import { Console, Effect, Layer, Context, Stream } from "effect" + * import { Console, Context, Effect, Layer, Stream } from "effect" * * class Env extends Context.Service()("Env") {} * @@ -12118,8 +13633,8 @@ export declare const ensuring: { * // ["Hello, Ada"] * ``` * + * @category services * @since 4.0.0 - * @category Services */ export declare const provide: { /** @@ -12127,11 +13642,10 @@ export declare const provide: { * service requirements. Use `options.local` to build the layer every time; by * default, layers are shared between provide calls. * - * **Previously Known As:** `provideSomeLayer`, `provideSomeContext`. + * **Example** (Providing stream requirements) * - * @example * ```ts - * import { Console, Effect, Layer, Context, Stream } from "effect" + * import { Console, Context, Effect, Layer, Stream } from "effect" * * class Env extends Context.Service()("Env") {} * @@ -12155,8 +13669,8 @@ export declare const provide: { * // ["Hello, Ada"] * ``` * + * @category services * @since 4.0.0 - * @category Services */ (layer: Layer.Layer | Context.Context, options?: { readonly local?: boolean | undefined; @@ -12166,11 +13680,10 @@ export declare const provide: { * service requirements. Use `options.local` to build the layer every time; by * default, layers are shared between provide calls. * - * **Previously Known As:** `provideSomeLayer`, `provideSomeContext`. + * **Example** (Providing stream requirements) * - * @example * ```ts - * import { Console, Effect, Layer, Context, Stream } from "effect" + * import { Console, Context, Effect, Layer, Stream } from "effect" * * class Env extends Context.Service()("Env") {} * @@ -12194,8 +13707,8 @@ export declare const provide: { * // ["Hello, Ada"] * ``` * + * @category services * @since 4.0.0 - * @category Services */ (self: Stream, layer: Layer.Layer | Context.Context, options?: { readonly local?: boolean | undefined; @@ -12204,9 +13717,10 @@ export declare const provide: { /** * Provides multiple services to the stream using a context. * - * @example + * **Example** (Providing multiple services to the stream using a context) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Config extends Context.Service()("Config") {} * class Greeter extends Context.Service string }>()("Greeter") {} @@ -12232,16 +13746,17 @@ export declare const provide: { * // ["Hello!"] * ``` * - * @since 4.0.0 - * @category Services + * @category services + * @since 2.0.0 */ export declare const provideContext: { /** * Provides multiple services to the stream using a context. * - * @example + * **Example** (Providing multiple services to the stream using a context) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Config extends Context.Service()("Config") {} * class Greeter extends Context.Service string }>()("Greeter") {} @@ -12267,16 +13782,17 @@ export declare const provideContext: { * // ["Hello!"] * ``` * - * @since 4.0.0 - * @category Services + * @category services + * @since 2.0.0 */ (context: Context.Context): (self: Stream) => Stream>; /** * Provides multiple services to the stream using a context. * - * @example + * **Example** (Providing multiple services to the stream using a context) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Config extends Context.Service()("Config") {} * class Greeter extends Context.Service string }>()("Greeter") {} @@ -12302,8 +13818,8 @@ export declare const provideContext: { * // ["Hello!"] * ``` * - * @since 4.0.0 - * @category Services + * @category services + * @since 2.0.0 */ (self: Stream, context: Context.Context): Stream>; }; @@ -12311,9 +13827,10 @@ export declare const provideContext: { * Provides the stream with a single required service, eliminating that * requirement from its environment. * - * @example + * **Example** (Providing a stream service) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Greeter extends Context.Service string @@ -12340,17 +13857,18 @@ export declare const provideContext: { * //=> ["Hello, Ada"] * ``` * - * @since 4.0.0 - * @category Services + * @category services + * @since 2.0.0 */ export declare const provideService: { /** * Provides the stream with a single required service, eliminating that * requirement from its environment. * - * @example + * **Example** (Providing a stream service) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Greeter extends Context.Service string @@ -12377,17 +13895,18 @@ export declare const provideService: { * //=> ["Hello, Ada"] * ``` * - * @since 4.0.0 - * @category Services + * @category services + * @since 2.0.0 */ (key: Context.Key, service: NoInfer): (self: Stream) => Stream>; /** * Provides the stream with a single required service, eliminating that * requirement from its environment. * - * @example + * **Example** (Providing a stream service) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Greeter extends Context.Service string @@ -12414,17 +13933,18 @@ export declare const provideService: { * //=> ["Hello, Ada"] * ``` * - * @since 4.0.0 - * @category Services + * @category services + * @since 2.0.0 */ (self: Stream, key: Context.Key, service: NoInfer): Stream>; }; /** * Provides a service to the stream using an effect, removing the requirement and adding the effect's error and environment. * - * @example + * **Example** (Providing a stream service effectfully) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class ApiConfig extends Context.Service()("ApiConfig") {} * @@ -12454,16 +13974,17 @@ export declare const provideService: { * // ["https://example.com"] * ``` * - * @since 4.0.0 - * @category Services + * @category services + * @since 2.0.0 */ export declare const provideServiceEffect: { /** * Provides a service to the stream using an effect, removing the requirement and adding the effect's error and environment. * - * @example + * **Example** (Providing a stream service effectfully) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class ApiConfig extends Context.Service()("ApiConfig") {} * @@ -12493,16 +14014,17 @@ export declare const provideServiceEffect: { * // ["https://example.com"] * ``` * - * @since 4.0.0 - * @category Services + * @category services + * @since 2.0.0 */ (key: Context.Key, service: Effect.Effect, ES, RS>): (self: Stream) => Stream | RS>; /** * Provides a service to the stream using an effect, removing the requirement and adding the effect's error and environment. * - * @example + * **Example** (Providing a stream service effectfully) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class ApiConfig extends Context.Service()("ApiConfig") {} * @@ -12532,8 +14054,8 @@ export declare const provideServiceEffect: { * // ["https://example.com"] * ``` * - * @since 4.0.0 - * @category Services + * @category services + * @since 2.0.0 */ (self: Stream, key: Context.Key, service: Effect.Effect, ES, RS>): Stream | RS>; }; @@ -12541,9 +14063,10 @@ export declare const provideServiceEffect: { * Transforms the stream's required services by mapping the current context * to a new one. * - * @example + * **Example** (Updating the stream context) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Logger extends Context.Service()("Logger") {} * class Config extends Context.Service()("Config") {} @@ -12573,17 +14096,18 @@ export declare const provideServiceEffect: { * //=> [ "Hello World" ] * ``` * - * @since 2.0.0 - * @category Services + * @category services + * @since 4.0.0 */ export declare const updateContext: { /** * Transforms the stream's required services by mapping the current context * to a new one. * - * @example + * **Example** (Updating the stream context) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Logger extends Context.Service()("Logger") {} * class Config extends Context.Service()("Config") {} @@ -12613,17 +14137,18 @@ export declare const updateContext: { * //=> [ "Hello World" ] * ``` * - * @since 2.0.0 - * @category Services + * @category services + * @since 4.0.0 */ (f: (context: Context.Context) => Context.Context): (self: Stream) => Stream; /** * Transforms the stream's required services by mapping the current context * to a new one. * - * @example + * **Example** (Updating the stream context) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Logger extends Context.Service()("Logger") {} * class Config extends Context.Service()("Config") {} @@ -12653,17 +14178,18 @@ export declare const updateContext: { * //=> [ "Hello World" ] * ``` * - * @since 2.0.0 - * @category Services + * @category services + * @since 4.0.0 */ (self: Stream, f: (context: Context.Context) => Context.Context): Stream; }; /** * Updates a single service in the stream environment by applying a function. * - * @example + * **Example** (Updating a stream service) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Counter extends Context.Service()("Counter") {} * @@ -12680,16 +14206,17 @@ export declare const updateContext: { * // Output: Updated count: 1 * ``` * + * @category services * @since 2.0.0 - * @category Services */ export declare const updateService: { /** * Updates a single service in the stream environment by applying a function. * - * @example + * **Example** (Updating a stream service) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Counter extends Context.Service()("Counter") {} * @@ -12706,16 +14233,17 @@ export declare const updateService: { * // Output: Updated count: 1 * ``` * + * @category services * @since 2.0.0 - * @category Services */ (key: Context.Key, f: (service: NoInfer) => S): (self: Stream) => Stream; /** * Updates a single service in the stream environment by applying a function. * - * @example + * **Example** (Updating a stream service) + * * ```ts - * import { Console, Effect, Context, Stream } from "effect" + * import { Console, Context, Effect, Stream } from "effect" * * class Counter extends Context.Service()("Counter") {} * @@ -12732,15 +14260,16 @@ export declare const updateService: { * // Output: Updated count: 1 * ``` * + * @category services * @since 2.0.0 - * @category Services */ (self: Stream, key: Context.Key, f: (service: NoInfer) => S): Stream; }; /** * Wraps the stream with a new span for tracing. * - * @example + * **Example** (Wrapping a stream in a span) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12755,14 +14284,15 @@ export declare const updateService: { * // [1, 2, 3] * ``` * - * @since 4.0.0 - * @category Tracing + * @category tracing + * @since 2.0.0 */ export declare const withSpan: { /** * Wraps the stream with a new span for tracing. * - * @example + * **Example** (Wrapping a stream in a span) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12777,14 +14307,15 @@ export declare const withSpan: { * // [1, 2, 3] * ``` * - * @since 4.0.0 - * @category Tracing + * @category tracing + * @since 2.0.0 */ (name: string, options?: SpanOptions): (self: Stream) => Stream>; /** * Wraps the stream with a new span for tracing. * - * @example + * **Example** (Wrapping a stream in a span) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12799,17 +14330,18 @@ export declare const withSpan: { * // [1, 2, 3] * ``` * - * @since 4.0.0 - * @category Tracing + * @category tracing + * @since 2.0.0 */ (self: Stream, name: string, options?: SpanOptions): Stream>; }; /** * Provides the entry point for do-notation style stream composition. * - * @example + * **Example** (Starting stream do notation) + * * ```ts - * import { Console, Effect, Stream, pipe } from "effect" + * import { Console, Effect, pipe, Stream } from "effect" * * const program = pipe( * Stream.Do, @@ -12826,8 +14358,8 @@ export declare const withSpan: { * //=> [{ value: 1, next: 2 }, { value: 2, next: 3 }] * ``` * - * @since 4.0.0 - * @category Do Notation + * @category do notation + * @since 2.0.0 */ export declare const Do: Stream<{}>; declare const let_: { @@ -12842,7 +14374,8 @@ export { /** * Adds a computed field to the current Do-notation record. * - * @example + * **Example** (Adding a computed field) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12860,14 +14393,15 @@ export { * // [{ x: 2, y: 6 }] * ``` * - * @since 4.0.0 - * @category Do Notation + * @category do notation + * @since 2.0.0 */ let_ as let }; /** * Binds the result of a stream to a field in the do-notation record. * - * @example + * **Example** (Binding a stream value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12882,14 +14416,15 @@ let_ as let }; * // [{ a: 1, b: 2 }, { a: 2, b: 3 }] * ``` * - * @since 4.0.0 - * @category Do Notation + * @category do notation + * @since 2.0.0 */ export declare const bind: { /** * Binds the result of a stream to a field in the do-notation record. * - * @example + * **Example** (Binding a stream value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12904,8 +14439,8 @@ export declare const bind: { * // [{ a: 1, b: 2 }, { a: 2, b: 3 }] * ``` * - * @since 4.0.0 - * @category Do Notation + * @category do notation + * @since 2.0.0 */ (tag: Exclude, f: (_: NoInfer) => Stream, options?: { readonly concurrency?: number | "unbounded" | undefined; @@ -12916,7 +14451,8 @@ export declare const bind: { /** * Binds the result of a stream to a field in the do-notation record. * - * @example + * **Example** (Binding a stream value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12931,8 +14467,8 @@ export declare const bind: { * // [{ a: 1, b: 2 }, { a: 2, b: 3 }] * ``` * - * @since 4.0.0 - * @category Do Notation + * @category do notation + * @since 2.0.0 */ (self: Stream, tag: Exclude, f: (_: NoInfer) => Stream, options?: { readonly concurrency?: number | "unbounded" | undefined; @@ -12944,7 +14480,8 @@ export declare const bind: { /** * Binds an Effect-produced value into the do-notation record for each stream element. * - * @example + * **Example** (Binding an effect value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12962,14 +14499,15 @@ export declare const bind: { * // [{ value: 1, double: 2 }, { value: 2, double: 4 }] * ``` * - * @since 4.0.0 - * @category Do Notation + * @category do notation + * @since 2.0.0 */ export declare const bindEffect: { /** * Binds an Effect-produced value into the do-notation record for each stream element. * - * @example + * **Example** (Binding an effect value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -12987,8 +14525,8 @@ export declare const bindEffect: { * // [{ value: 1, double: 2 }, { value: 2, double: 4 }] * ``` * - * @since 4.0.0 - * @category Do Notation + * @category do notation + * @since 2.0.0 */ (tag: Exclude, f: (_: NoInfer) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded" | undefined; @@ -13000,7 +14538,8 @@ export declare const bindEffect: { /** * Binds an Effect-produced value into the do-notation record for each stream element. * - * @example + * **Example** (Binding an effect value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13018,8 +14557,8 @@ export declare const bindEffect: { * // [{ value: 1, double: 2 }, { value: 2, double: 4 }] * ``` * - * @since 4.0.0 - * @category Do Notation + * @category do notation + * @since 2.0.0 */ (self: Stream, tag: Exclude, f: (_: NoInfer) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded" | undefined; @@ -13032,7 +14571,8 @@ export declare const bindEffect: { /** * Maps each element into a record keyed by the provided name. * - * @example + * **Example** (Binding values to a record key) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13044,14 +14584,15 @@ export declare const bindEffect: { * // [{ value: 1 }, { value: 2 }, { value: 3 }] * ``` * - * @category Do Notation - * @since 4.0.0 + * @category do notation + * @since 2.0.0 */ export declare const bindTo: { /** * Maps each element into a record keyed by the provided name. * - * @example + * **Example** (Binding values to a record key) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13063,8 +14604,8 @@ export declare const bindTo: { * // [{ value: 1 }, { value: 2 }, { value: 3 }] * ``` * - * @category Do Notation - * @since 4.0.0 + * @category do notation + * @since 2.0.0 */ (name: N): (self: Stream) => Stream<{ [K in N]: A; @@ -13072,7 +14613,8 @@ export declare const bindTo: { /** * Maps each element into a record keyed by the provided name. * - * @example + * **Example** (Binding values to a record key) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13084,8 +14626,8 @@ export declare const bindTo: { * // [{ value: 1 }, { value: 2 }, { value: 3 }] * ``` * - * @category Do Notation - * @since 4.0.0 + * @category do notation + * @since 2.0.0 */ (self: Stream, name: N): Stream<{ [K in N]: A; @@ -13094,7 +14636,8 @@ export declare const bindTo: { /** * Runs a stream with a sink and returns the sink result. * - * @example + * **Example** (Running a stream with a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -13104,14 +14647,15 @@ export declare const bindTo: { * // 6 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const run: { /** * Runs a stream with a sink and returns the sink result. * - * @example + * **Example** (Running a stream with a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -13121,14 +14665,15 @@ export declare const run: { * // 6 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (sink: Sink.Sink): (self: Stream) => Effect.Effect; /** * Runs a stream with a sink and returns the sink result. * - * @example + * **Example** (Running a stream with a sink) + * * ```ts * import { Console, Effect, Sink, Stream } from "effect" * @@ -13138,15 +14683,16 @@ export declare const run: { * // 6 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, sink: Sink.Sink): Effect.Effect; }; /** * Runs the stream and collects all elements into an array. * - * @example + * **Example** (Collecting stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13161,14 +14707,15 @@ export declare const run: { * // [1, 2, 3, 4, 5] * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runCollect: (self: Stream) => Effect.Effect, E, R>; /** * Runs the stream and returns the number of elements emitted. * - * @example + * **Example** (Counting stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13183,14 +14730,15 @@ export declare const runCollect: (self: Stream) => Effect.Effe * // 5 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runCount: (self: Stream) => Effect.Effect; /** * Runs the stream and returns the numeric sum of its elements. * - * @example + * **Example** (Summing stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13203,14 +14751,15 @@ export declare const runCount: (self: Stream) => Effect.Effect * // 6 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runSum: (self: Stream) => Effect.Effect; /** * Runs the stream and folds elements using a pure reducer. * - * @example + * **Example** (Folding stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13227,14 +14776,15 @@ export declare const runSum: (self: Stream) => Effect.Effect * // 6 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runFold: { /** * Runs the stream and folds elements using a pure reducer. * - * @example + * **Example** (Folding stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13251,14 +14801,15 @@ export declare const runFold: { * // 6 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (initial: LazyArg, f: (acc: Z, a: A) => Z): (self: Stream) => Effect.Effect; /** * Runs the stream and folds elements using a pure reducer. * - * @example + * **Example** (Folding stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13275,15 +14826,21 @@ export declare const runFold: { * // 6 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, initial: LazyArg, f: (acc: Z, a: A) => Z): Effect.Effect; }; /** * Runs the stream and folds elements using an effectful reducer. * - * @example + * **When to use** + * + * Use when reducing stream elements needs Effects, services, or failures in the + * reducer. + * + * **Example** (Effectfully folding stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13300,14 +14857,20 @@ export declare const runFold: { * // 6 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runFoldEffect: { /** * Runs the stream and folds elements using an effectful reducer. * - * @example + * **When to use** + * + * Use when reducing stream elements needs Effects, services, or failures in the + * reducer. + * + * **Example** (Effectfully folding stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13324,14 +14887,20 @@ export declare const runFoldEffect: { * // 6 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (initial: LazyArg, f: (acc: Z, a: A) => Effect.Effect): (self: Stream) => Effect.Effect; /** * Runs the stream and folds elements using an effectful reducer. * - * @example + * **When to use** + * + * Use when reducing stream elements needs Effects, services, or failures in the + * reducer. + * + * **Example** (Effectfully folding stream values) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13348,15 +14917,16 @@ export declare const runFoldEffect: { * // 6 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, initial: LazyArg, f: (acc: Z, a: A) => Effect.Effect): Effect.Effect; }; /** * Runs the stream and returns the first element as an `Option`. * - * @example + * **Example** (Getting the first stream value) + * * ```ts * import { Console, Effect, Option, Stream } from "effect" * @@ -13369,21 +14939,40 @@ export declare const runFoldEffect: { * // 1 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runHead: (self: Stream) => Effect.Effect, E, R>; /** * Runs the stream and returns the last element as an `Option`. * + * **When to use** + * + * Use to consume a finite stream when only the final emitted element matters. + * + * **Details** + * + * `Option.some` contains the last emitted element. `Option.none` means the + * stream completed without emitting. + * + * **Gotchas** + * + * The returned effect waits for the stream to complete before it can produce a + * value. + * + * @see {@link runHead} for consuming only the first emitted element + * @see {@link runCollect} for collecting every emitted element + * @see {@link runDrain} for consuming the stream while discarding emitted elements + * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runLast: (self: Stream) => Effect.Effect, E, R>; /** * Runs the provided effectful callback for each element of the stream. * - * @example + * **Example** (Running an effect for each value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13399,14 +14988,15 @@ export declare const runLast: (self: Stream) => Effect.Effect< * // Processing: 3 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runForEach: { /** * Runs the provided effectful callback for each element of the stream. * - * @example + * **Example** (Running an effect for each value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13422,14 +15012,15 @@ export declare const runForEach: { * // Processing: 3 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (f: (a: A) => Effect.Effect): (self: Stream) => Effect.Effect; /** * Runs the provided effectful callback for each element of the stream. * - * @example + * **Example** (Running an effect for each value) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13445,8 +15036,8 @@ export declare const runForEach: { * // Processing: 3 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, f: (a: A) => Effect.Effect): Effect.Effect; }; @@ -13454,7 +15045,8 @@ export declare const runForEach: { * Runs the stream, applying the effectful predicate to each element and * stopping when it returns `false`. * - * @example + * **Example** (Running effects while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13475,15 +15067,16 @@ export declare const runForEach: { * // Processing: 3 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runForEachWhile: { /** * Runs the stream, applying the effectful predicate to each element and * stopping when it returns `false`. * - * @example + * **Example** (Running effects while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13504,15 +15097,16 @@ export declare const runForEachWhile: { * // Processing: 3 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (f: (a: A) => Effect.Effect): (self: Stream) => Effect.Effect; /** * Runs the stream, applying the effectful predicate to each element and * stopping when it returns `false`. * - * @example + * **Example** (Running effects while a predicate holds) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13533,15 +15127,16 @@ export declare const runForEachWhile: { * // Processing: 3 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, f: (a: A) => Effect.Effect): Effect.Effect; }; /** * Consumes the stream in chunks, passing each non-empty array to the callback. * - * @example + * **Example** (Consuming stream chunks) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13557,14 +15152,15 @@ export declare const runForEachWhile: { * // Processing chunk: 1, 2, 3, 4, 5 * ``` * - * @since 2.0.0 - * @category Destructors + * @category destructors + * @since 4.0.0 */ export declare const runForEachArray: { /** * Consumes the stream in chunks, passing each non-empty array to the callback. * - * @example + * **Example** (Consuming stream chunks) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13580,14 +15176,15 @@ export declare const runForEachArray: { * // Processing chunk: 1, 2, 3, 4, 5 * ``` * - * @since 2.0.0 - * @category Destructors + * @category destructors + * @since 4.0.0 */ (f: (a: Arr.NonEmptyReadonlyArray) => Effect.Effect): (self: Stream) => Effect.Effect; /** * Consumes the stream in chunks, passing each non-empty array to the callback. * - * @example + * **Example** (Consuming stream chunks) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13603,15 +15200,16 @@ export declare const runForEachArray: { * // Processing chunk: 1, 2, 3, 4, 5 * ``` * - * @since 2.0.0 - * @category Destructors + * @category destructors + * @since 4.0.0 */ (self: Stream, f: (a: Arr.NonEmptyReadonlyArray) => Effect.Effect): Effect.Effect; }; /** * Runs the stream for its effects, discarding emitted elements. * - * @example + * **Example** (Draining a stream run) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13629,17 +15227,20 @@ export declare const runForEachArray: { * // Processing: 3 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runDrain: (self: Stream) => Effect.Effect; /** * Returns a scoped pull for manually consuming the stream's output chunks. * + * **Details** + * * The pull fails with `Cause.Done` when the stream ends and with the stream * error on failure. * - * @example + * **Example** (Creating a scoped pull) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13657,14 +15258,15 @@ export declare const runDrain: (self: Stream) => Effect.Effect * // [1, 2, 3] * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const toPull: (self: Stream) => Effect.Effect, E>, never, R | Scope.Scope>; /** * Concatenates all emitted strings into a single string. * - * @example + * **Example** (Joining strings from a stream) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13678,14 +15280,15 @@ export declare const toPull: (self: Stream) => Effect.Effect

(self: Stream) => Effect.Effect; /** * Concatenates the stream's `Uint8Array` chunks into a single `Uint8Array`. * - * @example + * **Example** (Joining Uint8Array chunks) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13699,16 +15302,24 @@ export declare const mkString: (self: Stream) => Effect.Effe * // [1, 2, 3, 4] * ``` * + * @category destructors * @since 4.0.0 - * @category Destructors */ export declare const mkUint8Array: (self: Stream) => Effect.Effect; /** * Converts the stream to a `ReadableStream` using the provided services. * + * **When to use** + * + * Use when bridging to Web Streams and you already have the `Context` required + * to run the stream outside an `Effect`. + * + * **Details** + * * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream. * - * @example + * **Example** (Converting to a ReadableStream with services) + * * ```ts * import { Context, Stream } from "effect" * @@ -13716,8 +15327,8 @@ export declare const mkUint8Array: (self: Stream) => Eff * const readableStream = Stream.toReadableStreamWith(stream, Context.empty()) * ``` * - * @since 2.0.0 - * @category Destructors + * @category destructors + * @since 4.0.0 */ export declare const toReadableStreamWith: ((context: Context.Context, options?: { readonly strategy?: QueuingStrategy | undefined; @@ -13727,9 +15338,12 @@ export declare const toReadableStreamWith: ((context: Context.Context /** * Converts a stream to a `ReadableStream`. * + * **Details** + * * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream. * - * @example + * **Example** (Converting a stream to a ReadableStream) + * * ```ts * import { Stream } from "effect" * @@ -13737,16 +15351,19 @@ export declare const toReadableStreamWith: ((context: Context.Context * const reader = readableStream.getReader() * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const toReadableStream: { /** * Converts a stream to a `ReadableStream`. * + * **Details** + * * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream. * - * @example + * **Example** (Converting a stream to a ReadableStream) + * * ```ts * import { Stream } from "effect" * @@ -13754,8 +15371,8 @@ export declare const toReadableStream: { * const reader = readableStream.getReader() * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (options?: { readonly strategy?: QueuingStrategy | undefined; @@ -13763,9 +15380,12 @@ export declare const toReadableStream: { /** * Converts a stream to a `ReadableStream`. * + * **Details** + * * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream. * - * @example + * **Example** (Converting a stream to a ReadableStream) + * * ```ts * import { Stream } from "effect" * @@ -13773,8 +15393,8 @@ export declare const toReadableStream: { * const reader = readableStream.getReader() * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, options?: { readonly strategy?: QueuingStrategy | undefined; @@ -13783,9 +15403,17 @@ export declare const toReadableStream: { /** * Creates an Effect that builds a ReadableStream from the stream. * + * **When to use** + * + * Use when bridging to Web Streams from inside an `Effect` so the required + * services can be captured from the current context. + * + * **Details** + * * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream. * - * @example + * **Example** (Creating a ReadableStream effect) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13799,16 +15427,24 @@ export declare const toReadableStream: { * Effect.runPromise(effect) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const toReadableStreamEffect: { /** * Creates an Effect that builds a ReadableStream from the stream. * + * **When to use** + * + * Use when bridging to Web Streams from inside an `Effect` so the required + * services can be captured from the current context. + * + * **Details** + * * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream. * - * @example + * **Example** (Creating a ReadableStream effect) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13822,8 +15458,8 @@ export declare const toReadableStreamEffect: { * Effect.runPromise(effect) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (options?: { readonly strategy?: QueuingStrategy | undefined; @@ -13831,9 +15467,17 @@ export declare const toReadableStreamEffect: { /** * Creates an Effect that builds a ReadableStream from the stream. * + * **When to use** + * + * Use when bridging to Web Streams from inside an `Effect` so the required + * services can be captured from the current context. + * + * **Details** + * * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream. * - * @example + * **Example** (Creating a ReadableStream effect) + * * ```ts * import { Console, Effect, Stream } from "effect" * @@ -13847,8 +15491,8 @@ export declare const toReadableStreamEffect: { * Effect.runPromise(effect) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, options?: { readonly strategy?: QueuingStrategy | undefined; @@ -13857,7 +15501,13 @@ export declare const toReadableStreamEffect: { /** * Converts the stream to an `AsyncIterable` using the provided services. * - * @example + * **When to use** + * + * Use when converting outside an Effect and you already have the `Context` + * needed to run the stream. + * + * **Example** (Converting to an AsyncIterable with services) + * * ```ts * import { Context, Stream } from "effect" * @@ -13869,18 +15519,27 @@ export declare const toReadableStreamEffect: { * for await (const value of iterable) { * results.push(value) * } - * return results + * console.log(results) * } + * + * collect() + * // [ 1, 2, 3 ] * ``` * - * @since 2.0.0 - * @category Destructors + * @category destructors + * @since 4.0.0 */ export declare const toAsyncIterableWith: { /** * Converts the stream to an `AsyncIterable` using the provided services. * - * @example + * **When to use** + * + * Use when converting outside an Effect and you already have the `Context` + * needed to run the stream. + * + * **Example** (Converting to an AsyncIterable with services) + * * ```ts * import { Context, Stream } from "effect" * @@ -13892,18 +15551,27 @@ export declare const toAsyncIterableWith: { * for await (const value of iterable) { * results.push(value) * } - * return results + * console.log(results) * } + * + * collect() + * // [ 1, 2, 3 ] * ``` * - * @since 2.0.0 - * @category Destructors + * @category destructors + * @since 4.0.0 */ (context: Context.Context): (self: Stream) => AsyncIterable; /** * Converts the stream to an `AsyncIterable` using the provided services. * - * @example + * **When to use** + * + * Use when converting outside an Effect and you already have the `Context` + * needed to run the stream. + * + * **Example** (Converting to an AsyncIterable with services) + * * ```ts * import { Context, Stream } from "effect" * @@ -13915,21 +15583,30 @@ export declare const toAsyncIterableWith: { * for await (const value of iterable) { * results.push(value) * } - * return results + * console.log(results) * } + * + * collect() + * // [ 1, 2, 3 ] * ``` * - * @since 2.0.0 - * @category Destructors + * @category destructors + * @since 4.0.0 */ (self: Stream, context: Context.Context): AsyncIterable; }; /** * Creates an effect that yields an `AsyncIterable` using the current services. * - * @example + * **When to use** + * + * Use when the `AsyncIterable` should be created inside Effect with the current + * context supplying the stream's services. + * + * **Example** (Creating an AsyncIterable effect) + * * ```ts - * import { Console, Effect, Stream } from "effect" + * import { Effect, Stream } from "effect" * * const stream = Stream.make(1, 2, 3) * @@ -13942,50 +15619,54 @@ export declare const toAsyncIterableWith: { * } * return collected * }) - * yield* Console.log(values) + * yield* Effect.sync(() => console.log(values)) * }) * * Effect.runPromise(program) - * //=> [ 1, 2, 3 ] + * // [ 1, 2, 3 ] * ``` * - * @since 2.0.0 - * @category Destructors + * @category destructors + * @since 3.15.0 */ export declare const toAsyncIterableEffect: (self: Stream) => Effect.Effect, never, R>; /** * Converts a stream to an `AsyncIterable` for `for await...of` consumption. * - * @example + * **Example** (Converting to an async iterable) + * * ```ts - * import { Effect, Stream } from "effect" + * import { Stream } from "effect" * * const stream = Stream.make(1, 2, 3) * - * const program = Effect.gen(function* () { + * const collect = async () => { * const iterable = Stream.toAsyncIterable(stream) - * const results = yield* Effect.promise(async () => { - * const values: Array = [] - * for await (const value of iterable) { - * values.push(value) - * } - * return values - * }) - * return results - * }) + * const values: Array = [] + * for await (const value of iterable) { + * values.push(value) + * } + * console.log(values) + * } + * + * collect() + * // [ 1, 2, 3 ] * ``` * - * @since 2.0.0 - * @category Destructors + * @category destructors + * @since 3.15.0 */ export declare const toAsyncIterable: (self: Stream) => AsyncIterable; /** * Runs the stream, publishing elements into the provided PubSub. * + * **Details** + * * `shutdownOnEnd` controls whether the PubSub is shut down when the stream ends. * It only shuts down when set to `true`. * - * @example + * **Example** (Running a stream into a PubSub) + * * ```ts * import { Console, Effect, PubSub, Stream } from "effect" * @@ -14007,17 +15688,20 @@ export declare const toAsyncIterable: (self: Stream) => AsyncIterabl * //=> 2 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runIntoPubSub: { /** * Runs the stream, publishing elements into the provided PubSub. * + * **Details** + * * `shutdownOnEnd` controls whether the PubSub is shut down when the stream ends. * It only shuts down when set to `true`. * - * @example + * **Example** (Running a stream into a PubSub) + * * ```ts * import { Console, Effect, PubSub, Stream } from "effect" * @@ -14039,8 +15723,8 @@ export declare const runIntoPubSub: { * //=> 2 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (pubsub: PubSub.PubSub, options?: { readonly shutdownOnEnd?: boolean | undefined; @@ -14048,10 +15732,13 @@ export declare const runIntoPubSub: { /** * Runs the stream, publishing elements into the provided PubSub. * + * **Details** + * * `shutdownOnEnd` controls whether the PubSub is shut down when the stream ends. * It only shuts down when set to `true`. * - * @example + * **Example** (Running a stream into a PubSub) + * * ```ts * import { Console, Effect, PubSub, Stream } from "effect" * @@ -14073,20 +15760,23 @@ export declare const runIntoPubSub: { * //=> 2 * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, pubsub: PubSub.PubSub, options?: { readonly shutdownOnEnd?: boolean | undefined; } | undefined): Effect.Effect; }; /** - * Converts a stream to a PubSub for concurrent consumption. + * Converts a stream to a PubSub of emitted values for concurrent consumption. + * + * **Details** * * `shutdownOnEnd` indicates whether the PubSub should be shut down when the * stream ends. By default this is `true`. * - * @example + * **Example** (Converting a stream to a PubSub for concurrent consumption) + * * ```ts * import { Console, Effect, PubSub, Stream } from "effect" * @@ -14101,17 +15791,20 @@ export declare const runIntoPubSub: { * })) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const toPubSub: { /** - * Converts a stream to a PubSub for concurrent consumption. + * Converts a stream to a PubSub of emitted values for concurrent consumption. + * + * **Details** * * `shutdownOnEnd` indicates whether the PubSub should be shut down when the * stream ends. By default this is `true`. * - * @example + * **Example** (Converting a stream to a PubSub for concurrent consumption) + * * ```ts * import { Console, Effect, PubSub, Stream } from "effect" * @@ -14126,8 +15819,8 @@ export declare const toPubSub: { * })) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (options: { readonly capacity: "unbounded"; @@ -14140,12 +15833,15 @@ export declare const toPubSub: { readonly shutdownOnEnd?: boolean | undefined; }): (self: Stream) => Effect.Effect, never, R | Scope.Scope>; /** - * Converts a stream to a PubSub for concurrent consumption. + * Converts a stream to a PubSub of emitted values for concurrent consumption. + * + * **Details** * * `shutdownOnEnd` indicates whether the PubSub should be shut down when the * stream ends. By default this is `true`. * - * @example + * **Example** (Converting a stream to a PubSub for concurrent consumption) + * * ```ts * import { Console, Effect, PubSub, Stream } from "effect" * @@ -14160,8 +15856,8 @@ export declare const toPubSub: { * })) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, options: { readonly capacity: "unbounded"; @@ -14175,11 +15871,14 @@ export declare const toPubSub: { }): Effect.Effect, never, R | Scope.Scope>; }; /** - * Converts a stream to a PubSub for concurrent consumption. + * Converts a stream to a PubSub of `Take` values for concurrent consumption. + * + * **Details** * * `Take` values include the stream's end and failure signals. * - * @example + * **Example** (Converting to a PubSub of takes) + * * ```ts * import { Console, Effect, PubSub, Stream } from "effect" * @@ -14196,16 +15895,19 @@ export declare const toPubSub: { * }) * ``` * + * @category destructors * @since 4.0.0 - * @category Destructors */ export declare const toPubSubTake: { /** - * Converts a stream to a PubSub for concurrent consumption. + * Converts a stream to a PubSub of `Take` values for concurrent consumption. + * + * **Details** * * `Take` values include the stream's end and failure signals. * - * @example + * **Example** (Converting to a PubSub of takes) + * * ```ts * import { Console, Effect, PubSub, Stream } from "effect" * @@ -14222,8 +15924,8 @@ export declare const toPubSubTake: { * }) * ``` * + * @category destructors * @since 4.0.0 - * @category Destructors */ (options: { readonly capacity: "unbounded"; @@ -14234,11 +15936,14 @@ export declare const toPubSubTake: { readonly replay?: number | undefined; }): (self: Stream) => Effect.Effect>, never, R | Scope.Scope>; /** - * Converts a stream to a PubSub for concurrent consumption. + * Converts a stream to a PubSub of `Take` values for concurrent consumption. + * + * **Details** * * `Take` values include the stream's end and failure signals. * - * @example + * **Example** (Converting to a PubSub of takes) + * * ```ts * import { Console, Effect, PubSub, Stream } from "effect" * @@ -14255,8 +15960,8 @@ export declare const toPubSubTake: { * }) * ``` * + * @category destructors * @since 4.0.0 - * @category Destructors */ (self: Stream, options: { readonly capacity: "unbounded"; @@ -14268,9 +15973,17 @@ export declare const toPubSubTake: { }): Effect.Effect>, never, R | Scope.Scope>; }; /** - * Converts a stream to a Queue for concurrent consumption. + * Creates a scoped dequeue that is fed by the stream for concurrent + * consumption. + * + * **Details** + * + * Elements are offered to the queue as the stream runs. Stream completion is + * signaled with `Cause.Done`, stream failures fail the queue, and the queue is + * shut down when the surrounding scope closes. + * + * **Example** (Converting a stream to a Queue for concurrent consumption) * - * @example * ```ts * import { Effect, Queue, Stream } from "effect" * @@ -14281,14 +15994,22 @@ export declare const toPubSubTake: { * }) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const toQueue: { /** - * Converts a stream to a Queue for concurrent consumption. + * Creates a scoped dequeue that is fed by the stream for concurrent + * consumption. + * + * **Details** + * + * Elements are offered to the queue as the stream runs. Stream completion is + * signaled with `Cause.Done`, stream failures fail the queue, and the queue is + * shut down when the surrounding scope closes. + * + * **Example** (Converting a stream to a Queue for concurrent consumption) * - * @example * ```ts * import { Effect, Queue, Stream } from "effect" * @@ -14299,8 +16020,8 @@ export declare const toQueue: { * }) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (options: { readonly capacity: "unbounded"; @@ -14309,9 +16030,17 @@ export declare const toQueue: { readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; }): (self: Stream) => Effect.Effect, never, R | Scope.Scope>; /** - * Converts a stream to a Queue for concurrent consumption. + * Creates a scoped dequeue that is fed by the stream for concurrent + * consumption. + * + * **Details** + * + * Elements are offered to the queue as the stream runs. Stream completion is + * signaled with `Cause.Done`, stream failures fail the queue, and the queue is + * shut down when the surrounding scope closes. + * + * **Example** (Converting a stream to a Queue for concurrent consumption) * - * @example * ```ts * import { Effect, Queue, Stream } from "effect" * @@ -14322,8 +16051,8 @@ export declare const toQueue: { * }) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, options: { readonly capacity: "unbounded"; @@ -14336,7 +16065,8 @@ export declare const toQueue: { * Runs the stream, offering each element to the provided queue and ending it * with `Cause.Done` when the stream completes. * - * @example + * **Example** (Running a stream into a queue) + * * ```ts * import { Cause, Effect, Queue, Stream } from "effect" * @@ -14358,15 +16088,16 @@ export declare const toQueue: { * }) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ export declare const runIntoQueue: { /** * Runs the stream, offering each element to the provided queue and ending it * with `Cause.Done` when the stream completes. * - * @example + * **Example** (Running a stream into a queue) + * * ```ts * import { Cause, Effect, Queue, Stream } from "effect" * @@ -14388,15 +16119,16 @@ export declare const runIntoQueue: { * }) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (queue: Queue.Queue): (self: Stream) => Effect.Effect; /** * Runs the stream, offering each element to the provided queue and ending it * with `Cause.Done` when the stream completes. * - * @example + * **Example** (Running a stream into a queue) + * * ```ts * import { Cause, Effect, Queue, Stream } from "effect" * @@ -14418,8 +16150,8 @@ export declare const runIntoQueue: { * }) * ``` * + * @category destructors * @since 2.0.0 - * @category Destructors */ (self: Stream, queue: Queue.Queue): Effect.Effect; };