/** * The `Channel` module provides a powerful abstraction for bi-directional communication * and streaming operations. A `Channel` is a nexus of I/O operations that supports both * reading and writing, forming the foundation for Effect's Stream and Sink abstractions. * * ## What is a Channel? * * A `Channel` represents: * - **OutElem**: The type of elements the channel outputs * - **OutErr**: The type of errors the channel can produce * - **OutDone**: The type of the final value when the channel completes * - **InElem**: The type of elements the channel reads * - **InErr**: The type of errors the channel can receive * - **InDone**: The type of the final value from upstream * - **Env**: The environment/context required by the channel * * ## Key Features * * - **Bi-directional**: Channels can both read and write * - **Composable**: Channels can be piped, sequenced, and concatenated * - **Resource-safe**: Automatic cleanup and resource management * - **Error-handling**: Built-in error propagation and handling * - **Concurrent**: Support for concurrent operations * * ## Composition Patterns * * 1. **Piping**: Connect channels where output of one becomes input of another * 2. **Sequencing**: Use the result of one channel to create another * 3. **Concatenating**: Combine multiple channels into a single channel * * @example * ```ts * import { Channel } from "effect" * * // Simple channel that outputs numbers * const numberChannel = Channel.succeed(42) * * // Transform channel that doubles values * const doubleChannel = Channel.map(numberChannel, (n) => n * 2) * * // Running the channel would output: 84 * ``` * * @example * ```ts * import { Channel } from "effect" * * // Channel from an array of values * const arrayChannel = Channel.fromArray([1, 2, 3, 4, 5]) * * // Transform the channel by mapping over values * const transformedChannel = Channel.map(arrayChannel, (n) => n * 2) * * // This channel will output: 2, 4, 6, 8, 10 * ``` * * @since 2.0.0 */ import * as Arr from "./Array.ts"; import * as Cause from "./Cause.ts"; import * as Chunk from "./Chunk.ts"; import * as Context from "./Context.ts"; import * as Effect from "./Effect.ts"; import * as Exit from "./Exit.ts"; import type * as Filter from "./Filter.ts"; import type { LazyArg } from "./Function.ts"; import * as Layer from "./Layer.ts"; import type { Severity } from "./LogLevel.ts"; import * as Option from "./Option.ts"; import type { Pipeable } from "./Pipeable.ts"; import type * as Predicate from "./Predicate.ts"; import * as PubSub from "./PubSub.ts"; import * as Pull from "./Pull.ts"; import * as Queue from "./Queue.ts"; import * as Schedule from "./Schedule.ts"; import * as Scope from "./Scope.ts"; import * as Take from "./Take.ts"; import { ParentSpan, type SpanOptions } from "./Tracer.ts"; import type * as Types from "./Types.ts"; import type * as Unify from "./Unify.ts"; /** * @since 4.0.0 * @category Type Identifiers */ export type TypeId = "~effect/Channel"; /** * @since 4.0.0 * @category Type Identifiers */ export declare const TypeId: TypeId; /** * Tests if a value is a `Channel`. * * @example * ```ts * import { Channel } from "effect" * * const channel = Channel.succeed(42) * console.log(Channel.isChannel(channel)) // true * console.log(Channel.isChannel("not a channel")) // false * ``` * * @category guards * @since 3.5.4 */ export declare const isChannel: (u: unknown) => u is Channel; /** * A `Channel` is a nexus of I/O operations, which supports both reading and * writing. A channel may read values of type `InElem` and write values of type * `OutElem`. When the channel finishes, it yields a value of type `OutDone`. A * channel may fail with a value of type `OutErr`. * * Channels are the foundation of Streams: both streams and sinks are built on * channels. Most users shouldn't have to use channels directly, as streams and * sinks are much more convenient and cover all common use cases. However, when * adding new stream and sink operators, or doing something highly specialized, * it may be useful to use channels directly. * * Channels compose in a variety of ways: * * - **Piping**: One channel can be piped to another channel, assuming the * input type of the second is the same as the output type of the first. * - **Sequencing**: The terminal value of one channel can be used to create * another channel, and both the first channel and the function that makes * the second channel can be composed into a channel. * - **Concatenating**: The output of one channel can be used to create other * channels, which are all concatenated together. The first channel and the * function that makes the other channels can be composed into a channel. * * @example * ```ts * import type { Channel } from "effect" * * // A channel that outputs numbers and requires no environment * type NumberChannel = Channel.Channel * * // A channel that outputs strings, can fail with Error, completes with boolean * type StringChannel = Channel.Channel * * // A channel with all type parameters specified * type FullChannel = Channel.Channel< * string, // OutElem - output elements * Error, // OutErr - output errors * number, // OutDone - completion value * number, // InElem - input elements * string, // InErr - input errors * boolean, // InDone - input completion * { db: string } // Env - required environment * > * ``` * * @since 2.0.0 * @category models */ export interface Channel extends Variance, Pipeable { [Unify.typeSymbol]?: unknown; [Unify.unifySymbol]?: ChannelUnify; [Unify.ignoreSymbol]?: ChannelUnifyIgnore; } /** * @since 2.0.0 * @category models */ export interface ChannelUnify extends Effect.EffectUnify { Channel?: () => A[Unify.typeSymbol] extends Channel | infer _ ? Channel : never; } /** * @category models * @since 2.0.0 */ export interface ChannelUnifyIgnore { Effect?: true; } type TagsWithReason = { [T in Types.Tags]: Types.ReasonTags> extends never ? never : T; }[Types.Tags]; /** * @since 2.0.0 * @category models */ export interface Variance { readonly [TypeId]: VarianceStruct; } /** * @since 2.0.0 * @category models */ export interface VarianceStruct { _Env: Types.Covariant; _InErr: Types.Contravariant; _InElem: Types.Contravariant; _InDone: Types.Contravariant; _OutErr: Types.Covariant; _OutElem: Types.Covariant; _OutDone: Types.Covariant; } /** * Creates a `Channel` from a transformation function that operates on upstream pulls. * * @example * ```ts * import { Channel, Effect } from "effect" * * const channel = Channel.fromTransform((upstream, scope) => * Effect.succeed(upstream) * ) * ``` * * @category constructors * @since 4.0.0 */ export declare const fromTransform: (transform: (upstream: Pull.Pull, scope: Scope.Scope) => Effect.Effect, EX, Env>) => Channel | EX, OutDone, InElem, InErr, InDone, Env | EnvX>; /** * Transforms a Channel by applying a function to its Pull implementation. * * @example * ```ts * import { Channel, Effect } from "effect" * * // Transform a channel by modifying its pull behavior * const originalChannel = Channel.fromIterable([1, 2, 3]) * * const transformedChannel = Channel.transformPull( * originalChannel, * (pull, scope) => * Effect.succeed( * Effect.map(pull, (value) => value * 2) * ) * ) * // Outputs: 2, 4, 6 * ``` * * @category constructors * @since 4.0.0 */ export declare const transformPull: (self: Channel, f: (pull: Pull.Pull, scope: Scope.Scope) => Effect.Effect, OutErrX, EnvX>) => Channel | OutErrX, OutDone2, InElem, InErr, InDone, Env | Env2 | EnvX>; /** * Creates a `Channel` from an `Effect` that produces a `Pull`. * * @example * ```ts * import { Channel, Effect } from "effect" * * const channel = Channel.fromPull( * Effect.succeed(Effect.succeed(42)) * ) * ``` * * @category constructors * @since 4.0.0 */ export declare const fromPull: (effect: Effect.Effect, EX, Env>) => Channel | EX, OutDone, unknown, unknown, unknown, Env | EnvX>; /** * Creates a `Channel` from a transformation function that operates on upstream * pulls, but also provides a forked scope that closes when the resulting * Channel completes. * * @since 4.0.0 * @category constructors */ export declare const fromTransformBracket: (f: (upstream: Pull.Pull, scope: Scope.Scope, forkedScope: Scope.Scope) => Effect.Effect, EX, Env>) => Channel | EX, OutDone, InElem, InErr, InDone, Env | EnvX>; /** * Converts a `Channel` back to its underlying transformation function. * * @example * ```ts * import { Channel } from "effect" * * const channel = Channel.succeed(42) * const transform = Channel.toTransform(channel) * // transform can now be used directly * ``` * * @category destructors * @since 4.0.0 */ export declare const toTransform: (channel: Channel) => (upstream: Pull.Pull, scope: Scope.Scope) => Effect.Effect, never, Env>; /** * The default chunk size used by channels for batching operations. * * @example * ```ts * import { Channel } from "effect" * * console.log(Channel.DefaultChunkSize) // 4096 * ``` * * @category constants * @since 2.0.0 */ export declare const DefaultChunkSize: number; /** * Creates a `Channel` that interacts with a callback function using a queue. * * @example * ```ts * import { Channel, Effect, Queue } from "effect" * * const channel = Channel.callback((queue) => * Effect.gen(function*() { * yield* Queue.offer(queue, 1) * yield* Queue.offer(queue, 2) * yield* Queue.offer(queue, 3) * }) * ) * ``` * * @category constructors * @since 2.0.0 */ export declare const callback: (f: (queue: Queue.Queue) => Effect.Effect, options?: { readonly bufferSize?: number | undefined; readonly strategy?: "sliding" | "dropping" | "suspend" | undefined; }) => Channel>; /** * Creates a `Channel` that interacts with a callback function using a queue, emitting arrays. * * @example * ```ts * import { Channel, Effect, Queue } from "effect" * * const channel = Channel.callbackArray(Effect.fn(function*(queue) { * yield* Queue.offer(queue, 1) * yield* Queue.offer(queue, 2) * })) * // Emits arrays of numbers instead of individual numbers * ``` * * @category constructors * @since 4.0.0 */ export declare const callbackArray: (f: (queue: Queue.Queue) => Effect.Effect, options?: { readonly bufferSize?: number | undefined; readonly strategy?: "sliding" | "dropping" | "suspend" | undefined; }) => Channel, E, void, unknown, unknown, unknown, Exclude>; /** * Creates a `Channel` that lazily evaluates to another channel. * * @example * ```ts * import { Channel } from "effect" * * const channel = Channel.suspend(() => Channel.succeed(42)) * // The inner channel is not created until the suspended channel is run * ``` * * @category constructors * @since 2.0.0 */ export declare const suspend: (evaluate: LazyArg>) => Channel; /** * Creates a `Channel` with resource management using acquire-use-release pattern. * * @example * ```ts * import { Channel, Effect } from "effect" * * const channel = Channel.acquireUseRelease( * Effect.succeed("resource"), * (resource) => Channel.succeed(resource.toUpperCase()), * (resource, exit) => Effect.log(`Released: ${resource}`) * ) * ``` * * @category constructors * @since 2.0.0 */ export declare const acquireUseRelease: (acquire: Effect.Effect, use: (a: A) => Channel, release: (a: A, exit: Exit.Exit) => Effect.Effect) => Channel; /** * Creates a `Channel` with resource management using acquire-release pattern. * * @example * ```ts * import { Channel, Effect } from "effect" * * const channel = Channel.acquireRelease( * Effect.succeed("resource"), * (resource, exit) => Effect.log(`Released: ${resource}`) * ) * ``` * * @category constructors * @since 2.0.0 */ export declare const acquireRelease: { /** * Creates a `Channel` with resource management using acquire-release pattern. * * @example * ```ts * import { Channel, Effect } from "effect" * * const channel = Channel.acquireRelease( * Effect.succeed("resource"), * (resource, exit) => Effect.log(`Released: ${resource}`) * ) * ``` * * @category constructors * @since 2.0.0 */ (release: (z: Z, e: Exit.Exit) => Effect.Effect): (self: Effect.Effect) => Channel; /** * Creates a `Channel` with resource management using acquire-release pattern. * * @example * ```ts * import { Channel, Effect } from "effect" * * const channel = Channel.acquireRelease( * Effect.succeed("resource"), * (resource, exit) => Effect.log(`Released: ${resource}`) * ) * ``` * * @category constructors * @since 2.0.0 */ (self: Effect.Effect, release: (z: Z, e: Exit.Exit) => Effect.Effect): Channel; }; /** * Creates a `Channel` from an iterator. * * @example * ```ts * import { Channel } from "effect" * * const numbers = [1, 2, 3, 4, 5] * const channel = Channel.fromIterator(() => numbers[Symbol.iterator]()) * // Emits: 1, 2, 3, 4, 5 * ``` * * @category constructors * @since 2.0.0 */ export declare const fromIterator: (iterator: LazyArg>) => Channel; /** * Creates a `Channel` that emits all elements from an array. * * @example * ```ts * import { Channel } from "effect" * * const channel = Channel.fromArray([1, 2, 3, 4, 5]) * // Emits: 1, 2, 3, 4, 5 * ``` * * @category constructors * @since 2.0.0 */ export declare const fromArray: (array: ReadonlyArray) => Channel; /** * Creates a `Channel` that emits all elements from a chunk. * * @example * ```ts * import { Channel, Chunk } from "effect" * * const chunk = Chunk.make(1, 2, 3) * const channel = Channel.fromChunk(chunk) * // Emits: 1, 2, 3 * ``` * * @category constructors * @since 2.0.0 */ export declare const fromChunk: (chunk: Chunk.Chunk) => Channel; /** * Creates a `Channel` from an iterator that emits arrays of elements. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel from a simple iterator * const numberIterator = (): Iterator => { * let count = 0 * return { * next: () => { * if (count < 3) { * return { value: count++, done: false } * } * return { value: "finished", done: true } * } * } * } * * const channel = Channel.fromIteratorArray(() => numberIterator(), 2) * // This will emit arrays: [0, 1], [2], then complete with "finished" * ``` * * @example * ```ts * import { Channel } from "effect" * * // Create channel from a generator function * function* fibonacci(): Generator { * let a = 0, b = 1 * for (let i = 0; i < 5; i++) { * yield a * ;[a, b] = [b, a + b] * } * } * * const fibChannel = Channel.fromIteratorArray(() => fibonacci(), 3) * // Emits: [0, 1, 1], [2, 3], then completes * ``` * * @since 2.0.0 * @category constructors */ export declare const fromIteratorArray: (iterator: LazyArg>, chunkSize?: number) => Channel, never, L>; /** * Creates a `Channel` that emits all elements from an iterable. * * @example * ```ts * import { Channel } from "effect" * * const set = new Set([1, 2, 3]) * const channel = Channel.fromIterable(set) * // Emits: 1, 2, 3 * ``` * * @category constructors * @since 2.0.0 */ export declare const fromIterable: (iterable: Iterable) => Channel; /** * Creates a `Channel` that emits arrays of elements from an iterable. * * @example * ```ts * import { Channel } from "effect" * * const numbers = [1, 2, 3, 4, 5] * const channel = Channel.fromIterableArray(numbers) * // Emits arrays like: [1, 2, 3, 4], [5] (based on chunk size) * ``` * * @category constructors * @since 2.0.0 */ export declare const fromIterableArray: (iterable: Iterable, chunkSize?: number) => Channel, never, L>; /** * Creates a `Channel` that emits a single value and then ends. * * @example * ```ts * import { Channel } from "effect" * * const channel = Channel.succeed(42) * // Emits: 42 * ``` * * @category constructors * @since 2.0.0 */ export declare const succeed: (value: A) => Channel; /** * Creates a `Channel` that immediately ends with the specified value. * * @example * ```ts * import { Channel } from "effect" * * const channel = Channel.end("done") * // Ends immediately with "done", emits nothing * ``` * * @category constructors * @since 4.0.0 */ export declare const end: (value: A) => Channel; /** * Creates a `Channel` that immediately ends with the lazily evaluated value. * * @category constructors * @since 4.0.0 */ export declare const endSync: (evaluate: LazyArg) => Channel; /** * Creates a `Channel` that emits a single value computed by a lazy evaluation. * * @example * ```ts * import { Channel } from "effect" * * const channel = Channel.sync(() => Math.random()) * // Emits a random number computed when the channel runs * ``` * * @category constructors * @since 2.0.0 */ export declare const sync: (evaluate: LazyArg) => Channel; /** * Represents an Channel that emits no elements * * @example * ```ts * import { Channel } from "effect" * * // Create an empty channel * const emptyChannel = Channel.empty * * // Use empty channel in composition * const combined = Channel.concatWith(emptyChannel, () => Channel.succeed(42)) * // Will immediately provide the second channel's output * * // Empty channel can be used as a no-op in conditional logic * const conditionalChannel = (shouldEmit: boolean) => * shouldEmit ? Channel.succeed("data") : Channel.empty * ``` * * @since 2.0.0 * @category constructors */ export declare const empty: Channel; /** * Represents an Channel that never completes * * @example * ```ts * import { Channel } from "effect" * * // Create a channel that never completes * const neverChannel = Channel.never * * // Use in conditional logic * const withFallback = Channel.concatWith( * neverChannel, * () => Channel.succeed("fallback") * ) * * // Never channel is useful for testing or as a placeholder * const conditionalChannel = (shouldComplete: boolean) => * shouldComplete ? Channel.succeed("done") : Channel.never * ``` * * @since 2.0.0 * @category constructors */ export declare const never: Channel; /** * Constructs a channel that fails immediately with the specified error. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel that fails with a string error * const failedChannel = Channel.fail("Something went wrong") * * // Create a channel that fails with a custom error * class CustomError extends Error { * constructor(message: string) { * super(message) * this.name = "CustomError" * } * } * const customErrorChannel = Channel.fail(new CustomError("Custom error")) * * // Use in error handling by piping to another channel * const channelWithFallback = Channel.concatWith( * failedChannel, * () => Channel.succeed("fallback value") * ) * ``` * * @since 2.0.0 * @category constructors */ export declare const fail: (error: E) => Channel; /** * Constructs a channel that fails immediately with the specified lazily * evaluated error. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel that fails with a lazily computed error * const failedChannel = Channel.failSync(() => { * console.log("Computing error...") * return new Error("Computed at runtime") * }) * * // The error computation is deferred until the channel runs * const conditionalError = Channel.failSync(() => * Math.random() > 0.5 ? "Error A" : "Error B" * ) * * // Use with expensive error construction * const expensiveError = Channel.failSync(() => { * const timestamp = Date.now() * return new Error(`Failed at: ${timestamp}`) * }) * ``` * * @since 2.0.0 * @category constructors */ export declare const failSync: (evaluate: LazyArg) => Channel; /** * Constructs a channel that fails immediately with the specified `Cause`. * * @example * ```ts * import { Cause, Channel } from "effect" * * // Create a channel that fails with a simple cause * const simpleCause = Cause.fail("Simple error") * const failedChannel = Channel.failCause(simpleCause) * * // Create a channel with a die cause * const dieCause = Cause.die(new Error("System error")) * const dieFailure = Channel.failCause(dieCause) * * // Create a channel with a simple fail cause * const failCause = Cause.fail("Simple error") * const simpleFail = Channel.failCause(failCause) * ``` * * @since 2.0.0 * @category constructors */ export declare const failCause: (cause: Cause.Cause) => Channel; /** * Constructs a channel that fails immediately with the specified lazily * evaluated `Cause`. * * @example * ```ts * import { Cause, Channel } from "effect" * * // Create a channel that fails with a lazily computed cause * const failedChannel = Channel.failCauseSync(() => { * const errorType = Math.random() > 0.5 ? "A" : "B" * return Cause.fail(`Runtime error ${errorType}`) * }) * * // Create a channel with die cause computation * const dieCauseChannel = Channel.failCauseSync(() => { * const timestamp = Date.now() * return Cause.die(`Error at ${timestamp}`) * }) * ``` * * @since 2.0.0 * @category constructors */ export declare const failCauseSync: (evaluate: LazyArg>) => Channel; /** * Constructs a channel that fails immediately with the specified defect. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel that dies with a string defect * const diedChannel = Channel.die("Unrecoverable error") * * // Create a channel that dies with an Error object * const errorDefect = Channel.die(new Error("System failure")) * * // Die with any value as a defect * const objectDefect = Channel.die({ * code: "SYSTEM_FAILURE", * details: "Critical system component failed" * }) * ``` * * @since 2.0.0 * @category constructors */ export declare const die: (defect: unknown) => Channel; /** * Use an effect to write a single value to the channel. * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class DatabaseError extends Data.TaggedError("DatabaseError")<{ * readonly message: string * }> {} * * // Create a channel from a successful effect * const successChannel = Channel.fromEffect( * Effect.succeed("Hello from effect!") * ) * * // Create a channel from an effect that might fail * const fetchUserChannel = Channel.fromEffect( * Effect.tryPromise({ * try: () => fetch("/api/user").then((res) => res.json()), * catch: (error) => new DatabaseError({ message: String(error) }) * }) * ) * * // Channel from effect with async computation * const asyncChannel = Channel.fromEffect( * Effect.gen(function*() { * yield* Effect.sleep("100 millis") * return "Async result" * }) * ) * ``` * * @since 2.0.0 * @category constructors */ export declare const fromEffect: (effect: Effect.Effect) => Channel, void, unknown, unknown, unknown, R>; /** * @since 4.0.0 * @category constructors */ export declare const fromEffectDone: (effect: Effect.Effect) => Channel, A, unknown, unknown, unknown, R>; /** * Use an effect and discard its result. * * @since 4.0.0 * @category constructors */ export declare const fromEffectDrain: (effect: Effect.Effect) => Channel; /** * @since 4.0.0 * @category constructors */ export declare const fromEffectTake: (effect: Effect.Effect, E2, R>) => Channel, E | E2, Done, unknown, unknown, unknown, R>; /** * Create a channel from a queue * * @example * ```ts * import { Channel, Data, Effect, Queue } from "effect" * * class QueueError extends Data.TaggedError("QueueError")<{ * readonly reason: string * }> {} * * const program = Effect.gen(function*() { * // Create a bounded queue * const queue = yield* Queue.bounded(10) * * // Add some items to the queue * yield* Queue.offer(queue, "item1") * yield* Queue.offer(queue, "item2") * yield* Queue.offer(queue, "item3") * * // Create a channel from the queue * const channel = Channel.fromQueue(queue) * * // The channel will read items from the queue one by one * return channel * }) * * // Sliding queue example * const slidingProgram = Effect.gen(function*() { * const slidingQueue = yield* Queue.sliding(5) * yield* Queue.offerAll(slidingQueue, [1, 2, 3, 4, 5, 6]) * return Channel.fromQueue(slidingQueue) * }) * ``` * * @since 4.0.0 * @category constructors */ export declare const fromQueue: (queue: Queue.Dequeue) => Channel>; /** * Create a channel from a queue that emits arrays of elements * * @example * ```ts * import { Channel, Data, Effect, Queue } from "effect" * * class ProcessingError extends Data.TaggedError("ProcessingError")<{ * readonly stage: string * }> {} * * const program = Effect.gen(function*() { * // Create a queue for batch processing * const queue = yield* Queue.bounded(100) * * // Fill queue with data * yield* Queue.offerAll(queue, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) * * // Create a channel that reads arrays from the queue * const arrayChannel = Channel.fromQueueArray(queue) * * // This will emit non-empty arrays of elements instead of individual items * // Useful for batch processing scenarios * return arrayChannel * }) * * // High-throughput processing example * const batchProcessor = Effect.gen(function*() { * const dataQueue = yield* Queue.dropping(1000) * const batchChannel = Channel.fromQueueArray(dataQueue) * * // Process data in batches for better performance * return Channel.map( * batchChannel, * (batch) => batch.map((item) => item.toUpperCase()) * ) * }) * ``` * * @since 4.0.0 * @category constructors */ export declare const fromQueueArray: (queue: Queue.Dequeue) => Channel, Exclude>; /** * @since 2.0.0 * @category Constructors */ export declare const identity: () => Channel; /** * Create a channel from a PubSub subscription * * @example * ```ts * import { Channel, Data, Effect, PubSub } from "effect" * * class SubscriptionError extends Data.TaggedError("SubscriptionError")<{ * readonly reason: string * }> {} * * const program = Effect.gen(function*() { * // Create a PubSub * const pubsub = yield* PubSub.bounded(32) * * // Create a subscription * const subscription = yield* PubSub.subscribe(pubsub) * * // Publish some messages * yield* PubSub.publish(pubsub, "Hello") * yield* PubSub.publish(pubsub, "World") * yield* PubSub.publish(pubsub, "from") * yield* PubSub.publish(pubsub, "PubSub") * * // Create a channel from the subscription * const channel = Channel.fromSubscription(subscription) * * // The channel will receive all published messages * return channel * }) * * // Real-time notifications example * const notificationChannel = Effect.gen(function*() { * const eventBus = yield* PubSub.unbounded<{ type: string; payload: any }>() * const userSubscription = yield* PubSub.subscribe(eventBus) * * return Channel.fromSubscription(userSubscription) * }) * ``` * * @since 4.0.0 * @category constructors */ export declare const fromSubscription: (subscription: PubSub.Subscription) => Channel; /** * Create a channel from a PubSub subscription that outputs arrays of values. * * This constructor creates a channel that reads from a PubSub subscription and outputs * arrays of values in chunks. It's useful when you want to process multiple values at once * for better performance. * * @param subscription - The PubSub subscription to read from * @param chunkSize - The maximum number of elements to read in each chunk (default: 4096) * * @example * ```ts * import { Channel, Data, Effect, PubSub } from "effect" * * class StreamError extends Data.TaggedError("StreamError")<{ * readonly message: string * }> {} * * const program = Effect.gen(function*() { * const pubsub = yield* PubSub.bounded(16) * const subscription = yield* PubSub.subscribe(pubsub) * * // Create a channel that reads arrays of values * const channel = Channel.fromSubscriptionArray(subscription) * * // Publish some values * yield* PubSub.publish(pubsub, 1) * yield* PubSub.publish(pubsub, 2) * yield* PubSub.publish(pubsub, 3) * yield* PubSub.publish(pubsub, 4) * * // The channel will output arrays like [1, 2, 3] and [4] * return channel * }) * ``` * * @example * ```ts * import { Channel, Data, Effect, PubSub } from "effect" * * class BatchProcessingError extends Data.TaggedError("BatchProcessingError")<{ * readonly reason: string * }> {} * * const batchProcessor = Effect.gen(function*() { * const pubsub = yield* PubSub.bounded(32) * const subscription = yield* PubSub.subscribe(pubsub) * * // Create a channel that processes items in batches * const batchChannel = Channel.fromSubscriptionArray(subscription) * * // Transform to process each batch * const processedChannel = Channel.map(batchChannel, (batch) => { * console.log(`Processing batch of ${batch.length} items:`, batch) * return batch.map((item) => item.toUpperCase()) * }) * * return processedChannel * }) * ``` * * @example * ```ts * import { Channel, Data, Effect, PubSub } from "effect" * * class MetricsError extends Data.TaggedError("MetricsError")<{ * readonly cause: string * }> {} * * const metricsAggregator = Effect.gen(function*() { * const metricsPubSub = yield* PubSub.bounded< * { timestamp: number; value: number } * >(100) * const subscription = yield* PubSub.subscribe(metricsPubSub) * * // Create a channel that collects metrics in chunks * const metricsChannel = Channel.fromSubscriptionArray(subscription) * * // Transform to calculate aggregate statistics * const aggregatedChannel = Channel.map(metricsChannel, (metrics) => { * const values = metrics.map((m) => m.value) * const sum = values.reduce((a, b) => a + b, 0) * const avg = sum / values.length * const min = Math.min(...values) * const max = Math.max(...values) * * return { * count: values.length, * sum, * average: avg, * min, * max, * timestamp: Date.now() * } * }) * * return aggregatedChannel * }) * ``` * * @since 4.0.0 * @category constructors */ export declare const fromSubscriptionArray: (subscription: PubSub.Subscription) => Channel>; /** * Create a channel from a PubSub that outputs individual values. * * This constructor creates a channel that reads from a PubSub by automatically * subscribing to it. The channel outputs individual values as they are published * to the PubSub, making it ideal for real-time streaming scenarios. * * @param pubsub - The PubSub to read from * * @example * ```ts * import { Channel, Data, Effect, PubSub } from "effect" * * class StreamError extends Data.TaggedError("StreamError")<{ * readonly message: string * }> {} * * const program = Effect.gen(function*() { * const pubsub = yield* PubSub.bounded(16) * * // Create a channel that reads individual values * const channel = Channel.fromPubSub(pubsub) * * // Publish some values * yield* PubSub.publish(pubsub, 1) * yield* PubSub.publish(pubsub, 2) * yield* PubSub.publish(pubsub, 3) * * // The channel will output: 1, 2, 3 (individual values) * return channel * }) * ``` * * @example * ```ts * import { Channel, Data, Effect, PubSub } from "effect" * * class NotificationError extends Data.TaggedError("NotificationError")<{ * readonly reason: string * }> {} * * const notificationService = Effect.gen(function*() { * const notificationPubSub = yield* PubSub.bounded(50) * * // Create a channel for real-time notifications * const notificationChannel = Channel.fromPubSub(notificationPubSub) * * // Transform notifications to add timestamps * const timestampedChannel = Channel.map(notificationChannel, (message) => ({ * message, * timestamp: new Date().toISOString(), * id: Math.random().toString(36).substr(2, 9) * })) * * return timestampedChannel * }) * ``` * * @example * ```ts * import { Channel, Data, Effect, PubSub } from "effect" * * class EventProcessingError extends Data.TaggedError("EventProcessingError")<{ * readonly eventType: string * readonly cause: string * }> {} * * interface DomainEvent { * readonly type: string * readonly payload: unknown * readonly timestamp: number * } * * const eventProcessor = Effect.gen(function*() { * const eventPubSub = yield* PubSub.bounded(100) * * // Create a channel for processing domain events * const eventChannel = Channel.fromPubSub(eventPubSub) * * // Filter and transform events * const processedChannel = Channel.map(eventChannel, (event) => { * if (event.type === "user.created") { * return { * ...event, * processed: true, * processedAt: Date.now() * } * } * return event * }) * * return processedChannel * }) * ``` * * @since 4.0.0 * @category constructors */ export declare const fromPubSub: (pubsub: PubSub.PubSub) => Channel; /** * Create a channel from a PubSub that outputs arrays of values. * * This constructor creates a channel that reads from a PubSub by automatically * subscribing to it and collecting values into arrays. The channel outputs * arrays of values in chunks, making it ideal for batch processing scenarios. * * @param pubsub - The PubSub to read from * @param chunkSize - The maximum number of elements to collect in each array (default: 4096) * * @example * ```ts * import { Channel, Data, Effect, PubSub } from "effect" * * class BatchError extends Data.TaggedError("BatchError")<{ * readonly message: string * }> {} * * const program = Effect.gen(function*() { * const pubsub = yield* PubSub.bounded(16) * * // Create a channel that reads arrays of values * const channel = Channel.fromPubSubArray(pubsub) * * // Publish some values * yield* PubSub.publish(pubsub, 1) * yield* PubSub.publish(pubsub, 2) * yield* PubSub.publish(pubsub, 3) * yield* PubSub.publish(pubsub, 4) * * // The channel will output arrays like [1, 2, 3] and [4] * return channel * }) * ``` * * @example * ```ts * import { Channel, Data, Effect, PubSub } from "effect" * * class OrderProcessingError extends Data.TaggedError("OrderProcessingError")<{ * readonly orderId: string * readonly reason: string * }> {} * * interface Order { * readonly id: string * readonly customerId: string * readonly items: ReadonlyArray * readonly total: number * } * * const orderBatchProcessor = Effect.gen(function*() { * const orderPubSub = yield* PubSub.bounded(100) * * // Create a channel that processes orders in batches * const orderChannel = Channel.fromPubSubArray(orderPubSub) * * // Transform to process each batch of orders * const processedChannel = Channel.map(orderChannel, (orderBatch) => { * const totalRevenue = orderBatch.reduce((sum, order) => sum + order.total, 0) * const customerCount = new Set(orderBatch.map((order) => * order.customerId * )).size * * return { * batchSize: orderBatch.length, * totalRevenue, * uniqueCustomers: customerCount, * processedAt: Date.now(), * orders: orderBatch * } * }) * * return processedChannel * }) * ``` * * @example * ```ts * import { Channel, Data, Effect, PubSub } from "effect" * * class LogProcessingError extends Data.TaggedError("LogProcessingError")<{ * readonly batchId: string * readonly cause: string * }> {} * * interface LogEntry { * readonly timestamp: number * readonly level: "info" | "warn" | "error" * readonly message: string * readonly source: string * } * * const logAggregator = Effect.gen(function*() { * const logPubSub = yield* PubSub.bounded(500) * * // Create a channel that collects logs in batches * const logChannel = Channel.fromPubSubArray(logPubSub) * * // Transform to analyze log batches * const analysisChannel = Channel.map(logChannel, (logBatch) => { * const errorCount = logBatch.filter((log) => log.level === "error").length * const warnCount = logBatch.filter((log) => log.level === "warn").length * const infoCount = logBatch.filter((log) => log.level === "info").length * * const timeRange = { * start: Math.min(...logBatch.map((log) => log.timestamp)), * end: Math.max(...logBatch.map((log) => log.timestamp)) * } * * return { * batchId: Math.random().toString(36).substr(2, 9), * totalEntries: logBatch.length, * errorCount, * warnCount, * infoCount, * timeRange, * sources: [...new Set(logBatch.map((log) => log.source))] * } * }) * * return analysisChannel * }) * ``` * * @since 4.0.0 * @category constructors */ export declare const fromPubSubArray: (pubsub: PubSub.PubSub) => Channel>; /** * @since 4.0.0 * @category constructors */ export declare const fromPubSubTake: (pubsub: PubSub.PubSub>) => Channel, E, Done>; /** * Creates a Channel from a Schedule. * * @since 4.0.0 * @category constructors */ export declare const fromSchedule: (schedule: Schedule.Schedule) => Channel; /** * Creates a Channel from a AsyncIterable. * * @since 4.0.0 * @category constructors */ export declare const fromAsyncIterable: (iterable: AsyncIterable, onError: (error: unknown) => E) => Channel; /** * Creates a Channel from a AsyncIterable that emits arrays of elements. * * @since 4.0.0 * @category constructors */ export declare const fromAsyncIterableArray: (iterable: AsyncIterable, onError: (error: unknown) => E) => Channel, E, D>; /** * Maps the output of this channel using the specified function. * * @example * ```ts * import { Channel, Data } from "effect" * * class TransformError extends Data.TaggedError("TransformError")<{ * readonly reason: string * }> {} * * // Basic mapping of channel values * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * const doubledChannel = Channel.map(numbersChannel, (n) => n * 2) * // Outputs: 2, 4, 6, 8, 10 * * // Transform string data * const wordsChannel = Channel.fromIterable(["hello", "world", "effect"]) * const upperCaseChannel = Channel.map(wordsChannel, (word) => word.toUpperCase()) * // Outputs: "HELLO", "WORLD", "EFFECT" * * // Complex object transformation * type User = { id: number; name: string } * type UserDisplay = { displayName: string; isActive: boolean } * * const usersChannel = Channel.fromIterable([ * { id: 1, name: "Alice" }, * { id: 2, name: "Bob" } * ]) * const displayChannel = Channel.map(usersChannel, (user): UserDisplay => ({ * displayName: `User: ${user.name}`, * isActive: true * })) * ``` * * @since 2.0.0 * @category Sequencing */ export declare const map: { /** * Maps the output of this channel using the specified function. * * @example * ```ts * import { Channel, Data } from "effect" * * class TransformError extends Data.TaggedError("TransformError")<{ * readonly reason: string * }> {} * * // Basic mapping of channel values * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * const doubledChannel = Channel.map(numbersChannel, (n) => n * 2) * // Outputs: 2, 4, 6, 8, 10 * * // Transform string data * const wordsChannel = Channel.fromIterable(["hello", "world", "effect"]) * const upperCaseChannel = Channel.map(wordsChannel, (word) => word.toUpperCase()) * // Outputs: "HELLO", "WORLD", "EFFECT" * * // Complex object transformation * type User = { id: number; name: string } * type UserDisplay = { displayName: string; isActive: boolean } * * const usersChannel = Channel.fromIterable([ * { id: 1, name: "Alice" }, * { id: 2, name: "Bob" } * ]) * const displayChannel = Channel.map(usersChannel, (user): UserDisplay => ({ * displayName: `User: ${user.name}`, * isActive: true * })) * ``` * * @since 2.0.0 * @category Sequencing */ (f: (o: OutElem, i: number) => OutElem2): (self: Channel) => Channel; /** * Maps the output of this channel using the specified function. * * @example * ```ts * import { Channel, Data } from "effect" * * class TransformError extends Data.TaggedError("TransformError")<{ * readonly reason: string * }> {} * * // Basic mapping of channel values * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * const doubledChannel = Channel.map(numbersChannel, (n) => n * 2) * // Outputs: 2, 4, 6, 8, 10 * * // Transform string data * const wordsChannel = Channel.fromIterable(["hello", "world", "effect"]) * const upperCaseChannel = Channel.map(wordsChannel, (word) => word.toUpperCase()) * // Outputs: "HELLO", "WORLD", "EFFECT" * * // Complex object transformation * type User = { id: number; name: string } * type UserDisplay = { displayName: string; isActive: boolean } * * const usersChannel = Channel.fromIterable([ * { id: 1, name: "Alice" }, * { id: 2, name: "Bob" } * ]) * const displayChannel = Channel.map(usersChannel, (user): UserDisplay => ({ * displayName: `User: ${user.name}`, * isActive: true * })) * ``` * * @since 2.0.0 * @category Sequencing */ (self: Channel, f: (o: OutElem, i: number) => OutElem2): Channel; }; /** * Maps the done value of this channel using the specified function. * * @since 2.0.0 * @category Sequencing */ export declare const mapDone: { /** * Maps the done value of this channel using the specified function. * * @since 2.0.0 * @category Sequencing */ (f: (o: OutDone) => OutDone2): (self: Channel) => Channel; /** * Maps the done value of this channel using the specified function. * * @since 2.0.0 * @category Sequencing */ (self: Channel, f: (o: OutDone) => OutDone2): Channel; }; /** * Maps the done value of this channel using the specified effectful function. * * @since 2.0.0 * @category Sequencing */ export declare const mapDoneEffect: { /** * Maps the done value of this channel using the specified effectful function. * * @since 2.0.0 * @category Sequencing */ (f: (o: OutDone) => Effect.Effect): (self: Channel) => Channel; /** * Maps the done value of this channel using the specified effectful function. * * @since 2.0.0 * @category Sequencing */ (self: Channel, f: (o: OutDone) => Effect.Effect): Channel; }; /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the output values of this channel. The result is a channel that will first * perform the functions of this channel, before performing the functions of * the created channel (including yielding its terminal value). * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class NetworkError extends Data.TaggedError("NetworkError")<{ * readonly url: string * }> {} * * // Transform values using effectful operations * const urlsChannel = Channel.fromIterable([ * "/api/users/1", * "/api/users/2", * "/api/users/3" * ]) * * const fetchDataChannel = Channel.mapEffect( * urlsChannel, * (url) => * Effect.tryPromise({ * try: () => fetch(url).then((res) => res.json()), * catch: () => new NetworkError({ url }) * }) * ) * * // Concurrent processing with options * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * const processedChannel = Channel.mapEffect( * numbersChannel, * (n) => * Effect.gen(function*() { * yield* Effect.sleep("100 millis") // Simulate async work * return n * n * }), * { concurrency: 3, unordered: true } * ) * ``` * * @since 2.0.0 * @category sequencing */ export declare const mapEffect: { /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the output values of this channel. The result is a channel that will first * perform the functions of this channel, before performing the functions of * the created channel (including yielding its terminal value). * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class NetworkError extends Data.TaggedError("NetworkError")<{ * readonly url: string * }> {} * * // Transform values using effectful operations * const urlsChannel = Channel.fromIterable([ * "/api/users/1", * "/api/users/2", * "/api/users/3" * ]) * * const fetchDataChannel = Channel.mapEffect( * urlsChannel, * (url) => * Effect.tryPromise({ * try: () => fetch(url).then((res) => res.json()), * catch: () => new NetworkError({ url }) * }) * ) * * // Concurrent processing with options * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * const processedChannel = Channel.mapEffect( * numbersChannel, * (n) => * Effect.gen(function*() { * yield* Effect.sleep("100 millis") // Simulate async work * return n * n * }), * { concurrency: 3, unordered: true } * ) * ``` * * @since 2.0.0 * @category sequencing */ (f: (d: OutElem, i: number) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded" | undefined; readonly unordered?: boolean | undefined; }): (self: Channel) => Channel; /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the output values of this channel. The result is a channel that will first * perform the functions of this channel, before performing the functions of * the created channel (including yielding its terminal value). * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class NetworkError extends Data.TaggedError("NetworkError")<{ * readonly url: string * }> {} * * // Transform values using effectful operations * const urlsChannel = Channel.fromIterable([ * "/api/users/1", * "/api/users/2", * "/api/users/3" * ]) * * const fetchDataChannel = Channel.mapEffect( * urlsChannel, * (url) => * Effect.tryPromise({ * try: () => fetch(url).then((res) => res.json()), * catch: () => new NetworkError({ url }) * }) * ) * * // Concurrent processing with options * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * const processedChannel = Channel.mapEffect( * numbersChannel, * (n) => * Effect.gen(function*() { * yield* Effect.sleep("100 millis") // Simulate async work * return n * n * }), * { concurrency: 3, unordered: true } * ) * ``` * * @since 2.0.0 * @category sequencing */ (self: Channel, f: (d: OutElem, i: number) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded" | undefined; readonly unordered?: boolean | undefined; }): Channel; }; /** * Returns a new channel which is the same as this one but applies the given * function to the input channel’s input elements. * * @since 2.0.0 * @category sequencing */ export declare const mapInput: { /** * Returns a new channel which is the same as this one but applies the given * function to the input channel’s input elements. * * @since 2.0.0 * @category sequencing */ (f: (i: InElem2) => Effect.Effect): (self: Channel) => Channel; /** * Returns a new channel which is the same as this one but applies the given * function to the input channel’s input elements. * * @since 2.0.0 * @category sequencing */ (self: Channel, f: (i: InElem2) => Effect.Effect): Channel; }; /** * Returns a new channel which is the same as this one but applies the given * function to the input errors. * * @since 2.0.0 * @category sequencing */ export declare const mapInputError: { /** * Returns a new channel which is the same as this one but applies the given * function to the input errors. * * @since 2.0.0 * @category sequencing */ (f: (i: InErr2) => Effect.Effect): (self: Channel) => Channel; /** * Returns a new channel which is the same as this one but applies the given * function to the input errors. * * @since 2.0.0 * @category sequencing */ (self: Channel, f: (i: InErr2) => Effect.Effect): Channel; }; /** * Applies a side effect function to each output element of the channel, * returning a new channel that emits the same elements. * * The `tap` function allows you to perform side effects (like logging or * debugging) on each element emitted by a channel without modifying the * elements themselves. * * @example * ```ts * import { Channel, Console, Data } from "effect" * * class LogError extends Data.TaggedError("LogError")<{ * readonly message: string * }> {} * * // Create a channel that outputs numbers * const numberChannel = Channel.fromIterable([1, 2, 3]) * * // Tap into each output element to perform side effects * const tappedChannel = Channel.tap( * numberChannel, * (n) => Console.log(`Processing number: ${n}`) * ) * * // The channel still outputs the same elements but logs each one * // Outputs: 1, 2, 3 (while logging each) * ``` * * @since 4.0.0 * @category sequencing */ export declare const tap: { /** * Applies a side effect function to each output element of the channel, * returning a new channel that emits the same elements. * * The `tap` function allows you to perform side effects (like logging or * debugging) on each element emitted by a channel without modifying the * elements themselves. * * @example * ```ts * import { Channel, Console, Data } from "effect" * * class LogError extends Data.TaggedError("LogError")<{ * readonly message: string * }> {} * * // Create a channel that outputs numbers * const numberChannel = Channel.fromIterable([1, 2, 3]) * * // Tap into each output element to perform side effects * const tappedChannel = Channel.tap( * numberChannel, * (n) => Console.log(`Processing number: ${n}`) * ) * * // The channel still outputs the same elements but logs each one * // Outputs: 1, 2, 3 (while logging each) * ``` * * @since 4.0.0 * @category sequencing */ (f: (d: Types.NoInfer) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded" | undefined; }): (self: Channel) => Channel; /** * Applies a side effect function to each output element of the channel, * returning a new channel that emits the same elements. * * The `tap` function allows you to perform side effects (like logging or * debugging) on each element emitted by a channel without modifying the * elements themselves. * * @example * ```ts * import { Channel, Console, Data } from "effect" * * class LogError extends Data.TaggedError("LogError")<{ * readonly message: string * }> {} * * // Create a channel that outputs numbers * const numberChannel = Channel.fromIterable([1, 2, 3]) * * // Tap into each output element to perform side effects * const tappedChannel = Channel.tap( * numberChannel, * (n) => Console.log(`Processing number: ${n}`) * ) * * // The channel still outputs the same elements but logs each one * // Outputs: 1, 2, 3 (while logging each) * ``` * * @since 4.0.0 * @category sequencing */ (self: Channel, f: (d: Types.NoInfer) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded" | undefined; }): Channel; }; /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the output values of this channel. The result is a channel that will first * perform the functions of this channel, before performing the functions of * the created channel (including yielding its terminal value). * * @example * ```ts * import { Channel, Data } from "effect" * * class ProcessError extends Data.TaggedError("ProcessError")<{ * readonly cause: string * }> {} * * // Create a channel that outputs numbers * const numberChannel = Channel.fromIterable([1, 2, 3]) * * // FlatMap each number to create new channels * const flatMappedChannel = Channel.flatMap( * numberChannel, * (n) => * Channel.fromIterable(Array.from({ length: n }, (_, i) => `item-${n}-${i}`)) * ) * * // Flattens nested channels into a single stream * // Outputs: "item-1-0", "item-2-0", "item-2-1", "item-3-0", "item-3-1", "item-3-2" * ``` * * @since 2.0.0 * @category sequencing */ export declare const flatMap: { /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the output values of this channel. The result is a channel that will first * perform the functions of this channel, before performing the functions of * the created channel (including yielding its terminal value). * * @example * ```ts * import { Channel, Data } from "effect" * * class ProcessError extends Data.TaggedError("ProcessError")<{ * readonly cause: string * }> {} * * // Create a channel that outputs numbers * const numberChannel = Channel.fromIterable([1, 2, 3]) * * // FlatMap each number to create new channels * const flatMappedChannel = Channel.flatMap( * numberChannel, * (n) => * Channel.fromIterable(Array.from({ length: n }, (_, i) => `item-${n}-${i}`)) * ) * * // Flattens nested channels into a single stream * // Outputs: "item-1-0", "item-2-0", "item-2-1", "item-3-0", "item-3-1", "item-3-2" * ``` * * @since 2.0.0 * @category sequencing */ (f: (d: OutElem) => Channel, options?: { readonly concurrency?: number | "unbounded" | undefined; readonly bufferSize?: number | undefined; }): (self: Channel) => Channel; /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the output values of this channel. The result is a channel that will first * perform the functions of this channel, before performing the functions of * the created channel (including yielding its terminal value). * * @example * ```ts * import { Channel, Data } from "effect" * * class ProcessError extends Data.TaggedError("ProcessError")<{ * readonly cause: string * }> {} * * // Create a channel that outputs numbers * const numberChannel = Channel.fromIterable([1, 2, 3]) * * // FlatMap each number to create new channels * const flatMappedChannel = Channel.flatMap( * numberChannel, * (n) => * Channel.fromIterable(Array.from({ length: n }, (_, i) => `item-${n}-${i}`)) * ) * * // Flattens nested channels into a single stream * // Outputs: "item-1-0", "item-2-0", "item-2-1", "item-3-0", "item-3-1", "item-3-2" * ``` * * @since 2.0.0 * @category sequencing */ (self: Channel, f: (d: OutElem) => Channel, options?: { readonly concurrency?: number | "unbounded" | undefined; readonly bufferSize?: number | undefined; }): Channel; }; /** * Concatenates this channel with another channel created from the terminal value * of this channel. The new channel is created using the provided function. * * @example * ```ts * import { Channel, Data } from "effect" * * class ConcatError extends Data.TaggedError("ConcatError")<{ * readonly reason: string * }> {} * * // Create a channel that outputs numbers and terminates with sum * const numberChannel = Channel.fromIterable([1, 2, 3]).pipe( * Channel.concatWith((sum: void) => Channel.succeed(`Completed processing`)) * ) * * // Concatenates additional channel based on completion value * // Outputs: 1, 2, 3, then "Completed processing" * ``` * * @since 2.0.0 * @category sequencing */ export declare const concatWith: { /** * Concatenates this channel with another channel created from the terminal value * of this channel. The new channel is created using the provided function. * * @example * ```ts * import { Channel, Data } from "effect" * * class ConcatError extends Data.TaggedError("ConcatError")<{ * readonly reason: string * }> {} * * // Create a channel that outputs numbers and terminates with sum * const numberChannel = Channel.fromIterable([1, 2, 3]).pipe( * Channel.concatWith((sum: void) => Channel.succeed(`Completed processing`)) * ) * * // Concatenates additional channel based on completion value * // Outputs: 1, 2, 3, then "Completed processing" * ``` * * @since 2.0.0 * @category sequencing */ (f: (leftover: Types.NoInfer) => Channel): (self: Channel) => Channel; /** * Concatenates this channel with another channel created from the terminal value * of this channel. The new channel is created using the provided function. * * @example * ```ts * import { Channel, Data } from "effect" * * class ConcatError extends Data.TaggedError("ConcatError")<{ * readonly reason: string * }> {} * * // Create a channel that outputs numbers and terminates with sum * const numberChannel = Channel.fromIterable([1, 2, 3]).pipe( * Channel.concatWith((sum: void) => Channel.succeed(`Completed processing`)) * ) * * // Concatenates additional channel based on completion value * // Outputs: 1, 2, 3, then "Completed processing" * ``` * * @since 2.0.0 * @category sequencing */ (self: Channel, f: (leftover: Types.NoInfer) => Channel): Channel; }; /** * Concatenates this channel with another channel, so that the second channel * starts emitting values after the first channel has completed. * * @example * ```ts * import { Channel, Data } from "effect" * * class ConcatError extends Data.TaggedError("ConcatError")<{ * readonly reason: string * }> {} * * // Create two channels * const firstChannel = Channel.fromIterable([1, 2, 3]) * const secondChannel = Channel.fromIterable(["a", "b", "c"]) * * // Concatenate them * const concatenatedChannel = Channel.concat(firstChannel, secondChannel) * * // Outputs: 1, 2, 3, "a", "b", "c" * ``` * * @since 2.0.0 * @category sequencing */ export declare const concat: { /** * Concatenates this channel with another channel, so that the second channel * starts emitting values after the first channel has completed. * * @example * ```ts * import { Channel, Data } from "effect" * * class ConcatError extends Data.TaggedError("ConcatError")<{ * readonly reason: string * }> {} * * // Create two channels * const firstChannel = Channel.fromIterable([1, 2, 3]) * const secondChannel = Channel.fromIterable(["a", "b", "c"]) * * // Concatenate them * const concatenatedChannel = Channel.concat(firstChannel, secondChannel) * * // Outputs: 1, 2, 3, "a", "b", "c" * ``` * * @since 2.0.0 * @category sequencing */ (that: Channel): (self: Channel) => Channel; /** * Concatenates this channel with another channel, so that the second channel * starts emitting values after the first channel has completed. * * @example * ```ts * import { Channel, Data } from "effect" * * class ConcatError extends Data.TaggedError("ConcatError")<{ * readonly reason: string * }> {} * * // Create two channels * const firstChannel = Channel.fromIterable([1, 2, 3]) * const secondChannel = Channel.fromIterable(["a", "b", "c"]) * * // Concatenate them * const concatenatedChannel = Channel.concat(firstChannel, secondChannel) * * // Outputs: 1, 2, 3, "a", "b", "c" * ``` * * @since 2.0.0 * @category sequencing */ (self: Channel, that: Channel): Channel; }; /** * Combines the elements from this channel and the specified channel by * repeatedly applying the function `f` to extract an element using both sides * and conceptually "offer" it to the destination channel. `f` can maintain * some internal state to control the combining process, with the initial * state being specified by `s`. * * @since 4.0.0 * @category sequencing */ export declare const combine: { /** * Combines the elements from this channel and the specified channel by * repeatedly applying the function `f` to extract an element using both sides * and conceptually "offer" it to the destination channel. `f` can maintain * some internal state to control the combining process, with the initial * state being specified by `s`. * * @since 4.0.0 * @category sequencing */ (that: Channel, s: LazyArg, f: (s: S, pullLeft: Pull.Pull, pullRight: Pull.Pull) => Effect.Effect): (self: Channel) => Channel, Cause.Done.Extract, InElem & InElem2, InErr & InErr2, InDone & InDone2, Env | Env2 | R>; /** * Combines the elements from this channel and the specified channel by * repeatedly applying the function `f` to extract an element using both sides * and conceptually "offer" it to the destination channel. `f` can maintain * some internal state to control the combining process, with the initial * state being specified by `s`. * * @since 4.0.0 * @category sequencing */ (self: Channel, that: Channel, s: LazyArg, f: (s: S, pullLeft: Pull.Pull, pullRight: Pull.Pull) => Effect.Effect): Channel, Cause.Done.Extract, InElem & InElem2, InErr & InErr2, InDone & InDone2, Env | Env2 | R>; }; /** * @since 2.0.0 * @category sequencing */ export declare const orElseIfEmpty: { /** * @since 2.0.0 * @category sequencing */ (f: (leftover: Types.NoInfer) => Channel): (self: Channel) => Channel; /** * @since 2.0.0 * @category sequencing */ (self: Channel, f: (leftover: Types.NoInfer) => Channel): Channel; }; /** * Flatten a channel of channels. * * @example * ```ts * import { Channel, Data } from "effect" * * class FlattenError extends Data.TaggedError("FlattenError")<{ * readonly cause: string * }> {} * * // Create a channel that outputs channels * const nestedChannels = Channel.fromIterable([ * Channel.fromIterable([1, 2]), * Channel.fromIterable([3, 4]), * Channel.fromIterable([5, 6]) * ]) * * // Flatten the nested channels * const flattenedChannel = Channel.flatten(nestedChannels) * * // Outputs: 1, 2, 3, 4, 5, 6 * ``` * * @since 2.0.0 * @category constructors */ export declare const flatten: (channels: Channel, OutErr1, OutDone1, InElem1, InErr1, InDone1, Env1>) => Channel; /** * Flattens a channel that outputs arrays into a channel that outputs individual elements. * * @example * ```ts * import { Channel, Data } from "effect" * * class FlattenError extends Data.TaggedError("FlattenError")<{ * readonly message: string * }> {} * * // Create a channel that outputs arrays * const arrayChannel = Channel.fromIterable([ * [1, 2, 3], * [4, 5], * [6, 7, 8, 9] * ]) * * // Flatten the arrays into individual elements * const flattenedChannel = Channel.flattenArray(arrayChannel) * * // Outputs: 1, 2, 3, 4, 5, 6, 7, 8, 9 * ``` * * @since 4.0.0 * @category utils */ export declare const flattenArray: (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>) => Channel; /** * @since 4.0.0 * @category utils */ export declare const flattenTake: (self: Channel, OutErr2, OutDone2, InElem, InErr, InDone, Env>) => Channel, OutErr | OutErr2, OutDone, InElem, InErr, InDone, Env>; /** * Creates a new channel that consumes all output from the source channel * but emits nothing, preserving only the completion value. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel that outputs values * const sourceChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Drain all output, keeping only the completion * const drainedChannel = Channel.drain(sourceChannel) * * // The channel completes but emits no values * // Useful for consuming side effects without collecting output * ``` * * @since 2.0.0 * @category constructors */ export declare const drain: (self: Channel) => Channel; /** * Repeats this channel according to the provided schedule. * * @since 4.0.0 * @category utils */ export declare const repeat: { /** * Repeats this channel according to the provided schedule. * * @since 4.0.0 * @category utils */ (schedule: Schedule.Schedule, SE, SR> | (($: (_: Schedule.Schedule, SE, SR>) => Schedule.Schedule) => Schedule.Schedule, SE, SR>)): (self: Channel) => Channel; /** * Repeats this channel according to the provided schedule. * * @since 4.0.0 * @category utils */ (self: Channel, schedule: Schedule.Schedule | (($: (_: Schedule.Schedule, SE, SR>) => Schedule.Schedule) => Schedule.Schedule, SE, SR>)): Channel; }; /** * Repeats this channel forever. * * @since 4.0.0 * @category utils */ export declare const forever: (self: Channel) => Channel; /** * @since 4.0.0 * @category utils */ export declare const schedule: { /** * @since 4.0.0 * @category utils */ (schedule: Schedule.Schedule, SE, SR>): (self: Channel) => Channel; /** * @since 4.0.0 * @category utils */ (self: Channel, schedule: Schedule.Schedule): Channel; }; /** * Filters the output elements of a channel using a predicate function. * Elements that don't match the predicate are discarded. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel with mixed numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5, 6, 7, 8]) * * // Filter to keep only even numbers * const evenChannel = Channel.filter(numbersChannel, (n) => n % 2 === 0) * // Outputs: 2, 4, 6, 8 * * // Filter with type refinement * const mixedChannel = Channel.fromIterable([1, "hello", 2, "world", 3]) * const numbersOnlyChannel = Channel.filter( * mixedChannel, * (value): value is number => typeof value === "number" * ) * // Outputs: 1, 2, 3 (all typed as numbers) * ``` * * @since 2.0.0 * @category Filtering */ export declare const filter: { /** * Filters the output elements of a channel using a predicate function. * Elements that don't match the predicate are discarded. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel with mixed numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5, 6, 7, 8]) * * // Filter to keep only even numbers * const evenChannel = Channel.filter(numbersChannel, (n) => n % 2 === 0) * // Outputs: 2, 4, 6, 8 * * // Filter with type refinement * const mixedChannel = Channel.fromIterable([1, "hello", 2, "world", 3]) * const numbersOnlyChannel = Channel.filter( * mixedChannel, * (value): value is number => typeof value === "number" * ) * // Outputs: 1, 2, 3 (all typed as numbers) * ``` * * @since 2.0.0 * @category Filtering */ (refinement: Predicate.Refinement): (self: Channel) => Channel; /** * Filters the output elements of a channel using a predicate function. * Elements that don't match the predicate are discarded. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel with mixed numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5, 6, 7, 8]) * * // Filter to keep only even numbers * const evenChannel = Channel.filter(numbersChannel, (n) => n % 2 === 0) * // Outputs: 2, 4, 6, 8 * * // Filter with type refinement * const mixedChannel = Channel.fromIterable([1, "hello", 2, "world", 3]) * const numbersOnlyChannel = Channel.filter( * mixedChannel, * (value): value is number => typeof value === "number" * ) * // Outputs: 1, 2, 3 (all typed as numbers) * ``` * * @since 2.0.0 * @category Filtering */ (predicate: Predicate.Predicate): (self: Channel) => Channel; /** * Filters the output elements of a channel using a predicate function. * Elements that don't match the predicate are discarded. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel with mixed numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5, 6, 7, 8]) * * // Filter to keep only even numbers * const evenChannel = Channel.filter(numbersChannel, (n) => n % 2 === 0) * // Outputs: 2, 4, 6, 8 * * // Filter with type refinement * const mixedChannel = Channel.fromIterable([1, "hello", 2, "world", 3]) * const numbersOnlyChannel = Channel.filter( * mixedChannel, * (value): value is number => typeof value === "number" * ) * // Outputs: 1, 2, 3 (all typed as numbers) * ``` * * @since 2.0.0 * @category Filtering */ (self: Channel, refinement: Predicate.Refinement): Channel; /** * Filters the output elements of a channel using a predicate function. * Elements that don't match the predicate are discarded. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel with mixed numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5, 6, 7, 8]) * * // Filter to keep only even numbers * const evenChannel = Channel.filter(numbersChannel, (n) => n % 2 === 0) * // Outputs: 2, 4, 6, 8 * * // Filter with type refinement * const mixedChannel = Channel.fromIterable([1, "hello", 2, "world", 3]) * const numbersOnlyChannel = Channel.filter( * mixedChannel, * (value): value is number => typeof value === "number" * ) * // Outputs: 1, 2, 3 (all typed as numbers) * ``` * * @since 2.0.0 * @category Filtering */ (self: Channel, predicate: Predicate.Predicate): Channel; }; /** * @since 4.0.0 * @category Filtering */ export declare const filterMap: { /** * @since 4.0.0 * @category Filtering */ (filter: Filter.Filter): (self: Channel) => Channel; /** * @since 4.0.0 * @category Filtering */ (self: Channel, filter: Filter.Filter): Channel; }; /** * @since 4.0.0 * @category Filtering */ export declare const filterEffect: { /** * @since 4.0.0 * @category Filtering */ (predicate: (a: OutElem) => Effect.Effect): (self: Channel) => Channel; /** * @since 4.0.0 * @category Filtering */ (self: Channel, predicate: (a: OutElem) => Effect.Effect): Channel; }; /** * @since 4.0.0 * @category Filtering */ export declare const filterMapEffect: { /** * @since 4.0.0 * @category Filtering */ (filter: Filter.FilterEffect): (self: Channel) => Channel; /** * @since 4.0.0 * @category Filtering */ (self: Channel, filter: Filter.FilterEffect): Channel; }; /** * Filters arrays of elements emitted by a channel, applying the filter * to each element within the arrays and only emitting non-empty filtered arrays. * * @example * ```ts * import { Array, Channel } from "effect" * * const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty * * // Create a channel that outputs arrays of mixed data * const arrayChannel = Channel.fromIterable([ * Array.make(1, 2, 3, 4, 5), * Array.make(6, 7, 8, 9, 10), * Array.make(11, 12, 13, 14, 15) * ]).pipe(Channel.filter(nonEmptyArrayPredicate)) * * // Filter arrays to keep only even numbers * const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0) * // Outputs: [2, 4], [6, 8, 10], [12, 14] * // Note: Only non-empty filtered arrays are emitted * * // Arrays that would become empty after filtering are discarded entirely * const oddChannel = Channel.fromIterable([ * Array.make(1, 3, 5), * Array.make(2, 4), * Array.make(7, 9) * ]).pipe(Channel.filter(nonEmptyArrayPredicate)) * const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0) * // Outputs: [2, 4] (the arrays [1,3,5] and [7,9] are discarded) * ``` * * @since 4.0.0 * @category Filtering */ export declare const filterArray: { /** * Filters arrays of elements emitted by a channel, applying the filter * to each element within the arrays and only emitting non-empty filtered arrays. * * @example * ```ts * import { Array, Channel } from "effect" * * const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty * * // Create a channel that outputs arrays of mixed data * const arrayChannel = Channel.fromIterable([ * Array.make(1, 2, 3, 4, 5), * Array.make(6, 7, 8, 9, 10), * Array.make(11, 12, 13, 14, 15) * ]).pipe(Channel.filter(nonEmptyArrayPredicate)) * * // Filter arrays to keep only even numbers * const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0) * // Outputs: [2, 4], [6, 8, 10], [12, 14] * // Note: Only non-empty filtered arrays are emitted * * // Arrays that would become empty after filtering are discarded entirely * const oddChannel = Channel.fromIterable([ * Array.make(1, 3, 5), * Array.make(2, 4), * Array.make(7, 9) * ]).pipe(Channel.filter(nonEmptyArrayPredicate)) * const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0) * // Outputs: [2, 4] (the arrays [1,3,5] and [7,9] are discarded) * ``` * * @since 4.0.0 * @category Filtering */ (refinement: Predicate.Refinement): (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>) => Channel, OutErr, OutDone, InElem, InErr, InDone, Env>; /** * Filters arrays of elements emitted by a channel, applying the filter * to each element within the arrays and only emitting non-empty filtered arrays. * * @example * ```ts * import { Array, Channel } from "effect" * * const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty * * // Create a channel that outputs arrays of mixed data * const arrayChannel = Channel.fromIterable([ * Array.make(1, 2, 3, 4, 5), * Array.make(6, 7, 8, 9, 10), * Array.make(11, 12, 13, 14, 15) * ]).pipe(Channel.filter(nonEmptyArrayPredicate)) * * // Filter arrays to keep only even numbers * const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0) * // Outputs: [2, 4], [6, 8, 10], [12, 14] * // Note: Only non-empty filtered arrays are emitted * * // Arrays that would become empty after filtering are discarded entirely * const oddChannel = Channel.fromIterable([ * Array.make(1, 3, 5), * Array.make(2, 4), * Array.make(7, 9) * ]).pipe(Channel.filter(nonEmptyArrayPredicate)) * const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0) * // Outputs: [2, 4] (the arrays [1,3,5] and [7,9] are discarded) * ``` * * @since 4.0.0 * @category Filtering */ (predicate: Predicate.Predicate>): (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>) => Channel, OutErr, OutDone, InElem, InErr, InDone, Env>; /** * Filters arrays of elements emitted by a channel, applying the filter * to each element within the arrays and only emitting non-empty filtered arrays. * * @example * ```ts * import { Array, Channel } from "effect" * * const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty * * // Create a channel that outputs arrays of mixed data * const arrayChannel = Channel.fromIterable([ * Array.make(1, 2, 3, 4, 5), * Array.make(6, 7, 8, 9, 10), * Array.make(11, 12, 13, 14, 15) * ]).pipe(Channel.filter(nonEmptyArrayPredicate)) * * // Filter arrays to keep only even numbers * const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0) * // Outputs: [2, 4], [6, 8, 10], [12, 14] * // Note: Only non-empty filtered arrays are emitted * * // Arrays that would become empty after filtering are discarded entirely * const oddChannel = Channel.fromIterable([ * Array.make(1, 3, 5), * Array.make(2, 4), * Array.make(7, 9) * ]).pipe(Channel.filter(nonEmptyArrayPredicate)) * const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0) * // Outputs: [2, 4] (the arrays [1,3,5] and [7,9] are discarded) * ``` * * @since 4.0.0 * @category Filtering */ (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>, refinement: Predicate.Refinement): Channel, OutErr, OutDone, InElem, InErr, InDone, Env>; /** * Filters arrays of elements emitted by a channel, applying the filter * to each element within the arrays and only emitting non-empty filtered arrays. * * @example * ```ts * import { Array, Channel } from "effect" * * const nonEmptyArrayPredicate = Array.isReadonlyArrayNonEmpty * * // Create a channel that outputs arrays of mixed data * const arrayChannel = Channel.fromIterable([ * Array.make(1, 2, 3, 4, 5), * Array.make(6, 7, 8, 9, 10), * Array.make(11, 12, 13, 14, 15) * ]).pipe(Channel.filter(nonEmptyArrayPredicate)) * * // Filter arrays to keep only even numbers * const evenArraysChannel = Channel.filterArray(arrayChannel, (n) => n % 2 === 0) * // Outputs: [2, 4], [6, 8, 10], [12, 14] * // Note: Only non-empty filtered arrays are emitted * * // Arrays that would become empty after filtering are discarded entirely * const oddChannel = Channel.fromIterable([ * Array.make(1, 3, 5), * Array.make(2, 4), * Array.make(7, 9) * ]).pipe(Channel.filter(nonEmptyArrayPredicate)) * const filteredOddChannel = Channel.filterArray(oddChannel, (n) => n % 2 === 0) * // Outputs: [2, 4] (the arrays [1,3,5] and [7,9] are discarded) * ``` * * @since 4.0.0 * @category Filtering */ (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>, predicate: Predicate.Predicate>): Channel, OutErr, OutDone, InElem, InErr, InDone, Env>; }; /** * @since 4.0.0 * @category Filtering */ export declare const filterMapArray: { /** * @since 4.0.0 * @category Filtering */ (filter: Filter.Filter, B, X>): (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>) => Channel, OutErr, OutDone, InElem, InErr, InDone, Env>; /** * @since 4.0.0 * @category Filtering */ (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>, filter: Filter.Filter): Channel, OutErr, OutDone, InElem, InErr, InDone, Env>; }; /** * @since 4.0.0 * @category Filtering */ export declare const filterArrayEffect: { /** * @since 4.0.0 * @category Filtering */ (predicate: (a: Types.NoInfer, index: number) => Effect.Effect): (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>) => Channel, OutErr | E, OutDone, InElem, InErr, InDone, Env | R>; /** * @since 4.0.0 * @category Filtering */ (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>, predicate: (a: Types.NoInfer, index: number) => Effect.Effect): Channel, OutErr | E, OutDone, InElem, InErr, InDone, Env | R>; }; /** * @since 4.0.0 * @category Filtering */ export declare const filterMapArrayEffect: { /** * @since 4.0.0 * @category Filtering */ (filter: Filter.FilterEffect, B, X, EX, RX>): (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>) => Channel, OutErr | EX, OutDone, InElem, InErr, InDone, Env | RX>; /** * @since 4.0.0 * @category Filtering */ (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>, filter: Filter.FilterEffect): Channel, OutErr | EX, OutDone, InElem, InErr, InDone, Env | RX>; }; /** * Statefully maps over a channel with an accumulator, where each element can produce multiple output values. * * @example * ```ts * import { Channel, Effect } from "effect" * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4]) * * // Use mapAccum to create running sums and emit both current and sum * const runningSum = Channel.mapAccum( * numbersChannel, * () => 0, // initial accumulator state * (sum, current) => { * const newSum = sum + current * // Return [newState, outputValues] * return [newSum, [current, newSum]] as const * } * ) * // Outputs: 1, 1, 2, 3, 3, 6, 4, 10 * * // Using with Effect for async processing * const asyncMapAccum = Channel.mapAccum( * numbersChannel, * () => "", * (acc, value) => * Effect.gen(function*() { * const newAcc = acc + value.toString() * return [newAcc, [`${value}-processed`, newAcc]] as const * }) * ) * ``` * * @since 2.0.0 * @category Sequencing */ export declare const mapAccum: { /** * Statefully maps over a channel with an accumulator, where each element can produce multiple output values. * * @example * ```ts * import { Channel, Effect } from "effect" * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4]) * * // Use mapAccum to create running sums and emit both current and sum * const runningSum = Channel.mapAccum( * numbersChannel, * () => 0, // initial accumulator state * (sum, current) => { * const newSum = sum + current * // Return [newState, outputValues] * return [newSum, [current, newSum]] as const * } * ) * // Outputs: 1, 1, 2, 3, 3, 6, 4, 10 * * // Using with Effect for async processing * const asyncMapAccum = Channel.mapAccum( * numbersChannel, * () => "", * (acc, value) => * Effect.gen(function*() { * const newAcc = acc + value.toString() * return [newAcc, [`${value}-processed`, newAcc]] as const * }) * ) * ``` * * @since 2.0.0 * @category Sequencing */ (initial: LazyArg, f: (s: S, a: Types.NoInfer) => Effect.Effect], E, R> | readonly [state: S, values: ReadonlyArray], options?: { readonly onHalt?: ((state: S) => Array) | undefined; }): (self: Channel) => Channel; /** * Statefully maps over a channel with an accumulator, where each element can produce multiple output values. * * @example * ```ts * import { Channel, Effect } from "effect" * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4]) * * // Use mapAccum to create running sums and emit both current and sum * const runningSum = Channel.mapAccum( * numbersChannel, * () => 0, // initial accumulator state * (sum, current) => { * const newSum = sum + current * // Return [newState, outputValues] * return [newSum, [current, newSum]] as const * } * ) * // Outputs: 1, 1, 2, 3, 3, 6, 4, 10 * * // Using with Effect for async processing * const asyncMapAccum = Channel.mapAccum( * numbersChannel, * () => "", * (acc, value) => * Effect.gen(function*() { * const newAcc = acc + value.toString() * return [newAcc, [`${value}-processed`, newAcc]] as const * }) * ) * ``` * * @since 2.0.0 * @category Sequencing */ (self: Channel, initial: LazyArg, f: (s: S, a: Types.NoInfer) => Effect.Effect], E, R> | readonly [state: S, values: ReadonlyArray], options?: { readonly onHalt?: ((state: S) => Array) | undefined; }): Channel; }; /** * Statefully transforms a channel by scanning over its output with an accumulator function. * Emits the intermediate results of the scan operation. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Scan to create running sum * const runningSumChannel = Channel.scan(numbersChannel, 0, (sum, n) => sum + n) * // Outputs: 0, 1, 3, 6, 10, 15 * // Note: emits the initial value and each intermediate result * * // Scan with string concatenation * const wordsChannel = Channel.fromIterable(["hello", "world", "from", "effect"]) * const sentenceChannel = Channel.scan( * wordsChannel, * "", * (sentence, word) => sentence === "" ? word : `${sentence} ${word}` * ) * // Outputs: "", "hello", "hello world", "hello world from", "hello world from effect" * ``` * * @since 2.0.0 * @category Sequencing */ export declare const scan: { /** * Statefully transforms a channel by scanning over its output with an accumulator function. * Emits the intermediate results of the scan operation. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Scan to create running sum * const runningSumChannel = Channel.scan(numbersChannel, 0, (sum, n) => sum + n) * // Outputs: 0, 1, 3, 6, 10, 15 * // Note: emits the initial value and each intermediate result * * // Scan with string concatenation * const wordsChannel = Channel.fromIterable(["hello", "world", "from", "effect"]) * const sentenceChannel = Channel.scan( * wordsChannel, * "", * (sentence, word) => sentence === "" ? word : `${sentence} ${word}` * ) * // Outputs: "", "hello", "hello world", "hello world from", "hello world from effect" * ``` * * @since 2.0.0 * @category Sequencing */ (initial: S, f: (s: S, a: Types.NoInfer) => S): (self: Channel) => Channel; /** * Statefully transforms a channel by scanning over its output with an accumulator function. * Emits the intermediate results of the scan operation. * * @example * ```ts * import { Channel } from "effect" * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Scan to create running sum * const runningSumChannel = Channel.scan(numbersChannel, 0, (sum, n) => sum + n) * // Outputs: 0, 1, 3, 6, 10, 15 * // Note: emits the initial value and each intermediate result * * // Scan with string concatenation * const wordsChannel = Channel.fromIterable(["hello", "world", "from", "effect"]) * const sentenceChannel = Channel.scan( * wordsChannel, * "", * (sentence, word) => sentence === "" ? word : `${sentence} ${word}` * ) * // Outputs: "", "hello", "hello world", "hello world from", "hello world from effect" * ``` * * @since 2.0.0 * @category Sequencing */ (self: Channel, initial: S, f: (s: S, a: Types.NoInfer) => S): Channel; }; /** * Statefully transforms a channel by scanning over its output with an effectful accumulator function. * Emits the intermediate results of the scan operation. * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class ScanError extends Data.TaggedError("ScanError")<{ * readonly reason: string * }> {} * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4]) * * // Effectful scan with async operations * const asyncScanChannel = Channel.scanEffect( * numbersChannel, * "", * (acc, value) => * Effect.gen(function*() { * // Simulate async work * yield* Effect.sleep("10 millis") * return acc + value.toString() * }) * ) * // Outputs: "", "1", "12", "123", "1234" * * // Scan with error handling * const errorHandlingScan = Channel.scanEffect( * numbersChannel, * 0, * (sum, n) => { * if (n < 0) { * return Effect.fail(new ScanError({ reason: "negative number" })) * } * return Effect.succeed(sum + n) * } * ) * ``` * * @since 2.0.0 * @category Sequencing */ export declare const scanEffect: { /** * Statefully transforms a channel by scanning over its output with an effectful accumulator function. * Emits the intermediate results of the scan operation. * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class ScanError extends Data.TaggedError("ScanError")<{ * readonly reason: string * }> {} * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4]) * * // Effectful scan with async operations * const asyncScanChannel = Channel.scanEffect( * numbersChannel, * "", * (acc, value) => * Effect.gen(function*() { * // Simulate async work * yield* Effect.sleep("10 millis") * return acc + value.toString() * }) * ) * // Outputs: "", "1", "12", "123", "1234" * * // Scan with error handling * const errorHandlingScan = Channel.scanEffect( * numbersChannel, * 0, * (sum, n) => { * if (n < 0) { * return Effect.fail(new ScanError({ reason: "negative number" })) * } * return Effect.succeed(sum + n) * } * ) * ``` * * @since 2.0.0 * @category Sequencing */ (initial: S, f: (s: S, a: Types.NoInfer) => Effect.Effect): (self: Channel) => Channel; /** * Statefully transforms a channel by scanning over its output with an effectful accumulator function. * Emits the intermediate results of the scan operation. * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class ScanError extends Data.TaggedError("ScanError")<{ * readonly reason: string * }> {} * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4]) * * // Effectful scan with async operations * const asyncScanChannel = Channel.scanEffect( * numbersChannel, * "", * (acc, value) => * Effect.gen(function*() { * // Simulate async work * yield* Effect.sleep("10 millis") * return acc + value.toString() * }) * ) * // Outputs: "", "1", "12", "123", "1234" * * // Scan with error handling * const errorHandlingScan = Channel.scanEffect( * numbersChannel, * 0, * (sum, n) => { * if (n < 0) { * return Effect.fail(new ScanError({ reason: "negative number" })) * } * return Effect.succeed(sum + n) * } * ) * ``` * * @since 2.0.0 * @category Sequencing */ (self: Channel, initial: S, f: (s: S, a: Types.NoInfer) => Effect.Effect): Channel; }; /** * Catches any cause of failure from the channel and allows recovery by * creating a new channel based on the caught cause. * * @example * ```ts * import { Cause, Channel, Data } from "effect" * * class ProcessError extends Data.TaggedError("ProcessError")<{ * readonly reason: string * }> {} * * class RecoveryError extends Data.TaggedError("RecoveryError")<{ * readonly message: string * }> {} * * // Create a failing channel * const failingChannel = Channel.fail( * new ProcessError({ reason: "network error" }) * ) * * // Catch the cause and provide recovery * const recoveredChannel = Channel.catchCause(failingChannel, (cause) => { * if (Cause.hasFails(cause)) { * return Channel.succeed("Recovered from failure") * } * return Channel.succeed("Recovered from interruption") * }) * * // The channel recovers gracefully from errors * ``` * * @since 4.0.0 * @category Error handling */ export declare const catchCause: { /** * Catches any cause of failure from the channel and allows recovery by * creating a new channel based on the caught cause. * * @example * ```ts * import { Cause, Channel, Data } from "effect" * * class ProcessError extends Data.TaggedError("ProcessError")<{ * readonly reason: string * }> {} * * class RecoveryError extends Data.TaggedError("RecoveryError")<{ * readonly message: string * }> {} * * // Create a failing channel * const failingChannel = Channel.fail( * new ProcessError({ reason: "network error" }) * ) * * // Catch the cause and provide recovery * const recoveredChannel = Channel.catchCause(failingChannel, (cause) => { * if (Cause.hasFails(cause)) { * return Channel.succeed("Recovered from failure") * } * return Channel.succeed("Recovered from interruption") * }) * * // The channel recovers gracefully from errors * ``` * * @since 4.0.0 * @category Error handling */ (f: (d: Cause.Cause) => Channel): (self: Channel) => Channel; /** * Catches any cause of failure from the channel and allows recovery by * creating a new channel based on the caught cause. * * @example * ```ts * import { Cause, Channel, Data } from "effect" * * class ProcessError extends Data.TaggedError("ProcessError")<{ * readonly reason: string * }> {} * * class RecoveryError extends Data.TaggedError("RecoveryError")<{ * readonly message: string * }> {} * * // Create a failing channel * const failingChannel = Channel.fail( * new ProcessError({ reason: "network error" }) * ) * * // Catch the cause and provide recovery * const recoveredChannel = Channel.catchCause(failingChannel, (cause) => { * if (Cause.hasFails(cause)) { * return Channel.succeed("Recovered from failure") * } * return Channel.succeed("Recovered from interruption") * }) * * // The channel recovers gracefully from errors * ``` * * @since 4.0.0 * @category Error handling */ (self: Channel, f: (d: Cause.Cause) => Channel): Channel; }; /** * @since 4.0.0 * @category Error handling */ export declare const tapCause: { /** * @since 4.0.0 * @category Error handling */ (f: (d: Cause.Cause) => Effect.Effect): (self: Channel) => Channel; /** * @since 4.0.0 * @category Error handling */ (self: Channel, f: (d: Cause.Cause) => Effect.Effect): Channel; }; /** * Catches causes of failure that match a specific filter, allowing * conditional error recovery based on the type of failure. * * @since 4.0.0 * @category Error handling */ export declare const catchCauseIf: { /** * Catches causes of failure that match a specific filter, allowing * conditional error recovery based on the type of failure. * * @since 4.0.0 * @category Error handling */ (predicate: Predicate.Predicate>, f: (cause: Cause.Cause) => Channel): (self: Channel) => Channel; /** * Catches causes of failure that match a specific filter, allowing * conditional error recovery based on the type of failure. * * @since 4.0.0 * @category Error handling */ (self: Channel, predicate: Predicate.Predicate>, f: (cause: Cause.Cause) => Channel): Channel; }; /** * @since 4.0.0 * @category Error handling */ export declare const catchCauseFilter: { /** * @since 4.0.0 * @category Error handling */ , OutElem1, OutErr1, OutDone1, InElem1, InErr1, InDone1, Env1>(filter: Filter.Filter, EB, X>, f: (failure: EB, cause: Cause.Cause) => Channel): (self: Channel) => Channel | OutErr1, OutDone | OutDone1, InElem & InElem1, InErr & InErr1, InDone & InDone1, Env | Env1>; /** * @since 4.0.0 * @category Error handling */ , OutElem1, OutErr1, OutDone1, InElem1, InErr1, InDone1, Env1>(self: Channel, filter: Filter.Filter, EB, X>, f: (failure: EB, cause: Cause.Cause) => Channel): Channel | OutErr1, OutDone | OutDone1, InElem & InElem1, InErr & InErr1, InDone & InDone1, Env | Env1>; }; declare const catch_: { (f: (d: OutErr) => Channel): (self: Channel) => Channel; (self: Channel, f: (d: OutErr) => Channel): Channel; }; export { /** * @since 4.0.0 * @category Error handling */ catch_ as catch }; /** * @since 4.0.0 * @category Error handling */ export declare const tapError: { /** * @since 4.0.0 * @category Error handling */ (f: (d: OutErr) => Effect.Effect): (self: Channel) => Channel; /** * @since 4.0.0 * @category Error handling */ (self: Channel, f: (d: OutErr) => Effect.Effect): Channel; }; /** * @since 4.0.0 * @category Error handling */ export declare const catchIf: { /** * @since 4.0.0 * @category Error handling */ , OutDone2 = never, InElem2 = unknown, InErr2 = unknown, InDone2 = unknown, Env2 = never>(refinement: Predicate.Refinement, f: (failure: EB) => Channel, orElse?: ((failure: Exclude) => Channel) | undefined): (self: Channel) => Channel; /** * @since 4.0.0 * @category Error handling */ (predicate: Predicate.Predicate, f: (failure: OutErr) => Channel, orElse?: ((failure: OutErr) => Channel) | undefined): (self: Channel) => Channel; /** * @since 4.0.0 * @category Error handling */ , OutDone2 = never, InElem2 = unknown, InErr2 = unknown, InDone2 = unknown, Env2 = never>(self: Channel, refinement: Predicate.Refinement, f: (failure: EB) => Channel, orElse?: ((failure: Exclude) => Channel) | undefined): Channel; /** * @since 4.0.0 * @category Error handling */ (self: Channel, predicate: Predicate.Predicate, f: (failure: OutErr) => Channel, orElse?: ((failure: OutErr) => Channel) | undefined): Channel; }; /** * @since 4.0.0 * @category Error handling */ export declare const catchFilter: { /** * @since 4.0.0 * @category Error handling */ (filter: Filter.Filter, f: (failure: EB) => Channel, orElse?: ((failure: X) => Channel) | undefined): (self: Channel) => Channel; /** * @since 4.0.0 * @category Error handling */ (self: Channel, filter: Filter.Filter, f: (failure: EB) => Channel, orElse?: ((failure: X) => Channel) | undefined): Channel; }; /** * @since 4.0.0 * @category Error handling */ export declare const catchTag: { /** * @since 4.0.0 * @category Error handling */ | Arr.NonEmptyReadonlyArray>, OutElem1, OutErr1, OutDone1, InElem1, InErr1, InDone1, Env1, OutElem2 = never, OutErr2 = Types.ExcludeTag ? K[number] : K>, OutDone2 = never, InElem2 = unknown, InErr2 = unknown, InDone2 = unknown, Env2 = never>(k: K, f: (e: Types.ExtractTag, K extends Arr.NonEmptyReadonlyArray ? K[number] : K>) => Channel, orElse?: ((e: Types.ExcludeTag, K extends Arr.NonEmptyReadonlyArray ? K[number] : K>) => Channel) | undefined): (self: Channel) => Channel; /** * @since 4.0.0 * @category Error handling */ | Arr.NonEmptyReadonlyArray>, OutElem1, OutErr1, OutDone1, InElem1, InErr1, InDone1, Env1, OutElem2 = never, OutErr2 = Types.ExcludeTag ? K[number] : K>, OutDone2 = never, InElem2 = unknown, InErr2 = unknown, InDone2 = unknown, Env2 = never>(self: Channel, k: K, f: (e: Types.ExtractTag, K extends Arr.NonEmptyReadonlyArray ? K[number] : K>) => Channel, orElse?: ((e: Types.ExcludeTag, K extends Arr.NonEmptyReadonlyArray ? K[number] : K>) => Channel) | undefined): Channel; }; /** * Catches a specific reason within a tagged error. * * @example * ```ts * import { Channel, Data } from "effect" * * class RateLimitError extends Data.TaggedError("RateLimitError")<{ * retryAfter: number * }> {} * * class QuotaExceededError extends Data.TaggedError("QuotaExceededError")<{ * limit: number * }> {} * * class AiError extends Data.TaggedError("AiError")<{ * reason: RateLimitError | QuotaExceededError * }> {} * * const channel = Channel.fail( * new AiError({ reason: new RateLimitError({ retryAfter: 60 }) }) * ) * * const recovered = channel.pipe( * Channel.catchReason("AiError", "RateLimitError", (reason) => * Channel.succeed(`retry: ${reason.retryAfter}`) * ) * ) * ``` * * @since 4.0.0 * @category Error handling */ export declare const catchReason: { /** * Catches a specific reason within a tagged error. * * @example * ```ts * import { Channel, Data } from "effect" * * class RateLimitError extends Data.TaggedError("RateLimitError")<{ * retryAfter: number * }> {} * * class QuotaExceededError extends Data.TaggedError("QuotaExceededError")<{ * limit: number * }> {} * * class AiError extends Data.TaggedError("AiError")<{ * reason: RateLimitError | QuotaExceededError * }> {} * * const channel = Channel.fail( * new AiError({ reason: new RateLimitError({ retryAfter: 60 }) }) * ) * * const recovered = channel.pipe( * Channel.catchReason("AiError", "RateLimitError", (reason) => * Channel.succeed(`retry: ${reason.retryAfter}`) * ) * ) * ``` * * @since 4.0.0 * @category Error handling */ , RK extends Types.ReasonTags, K>>, OutElem1, OutErr1, OutDone1, InElem1, InErr1, InDone1, Env1, OutElem2 = Types.unassigned, OutErr2 = never, OutDone2 = never, InElem2 = unknown, InErr2 = unknown, InDone2 = unknown, Env2 = never>(errorTag: K, reasonTag: RK, f: (reason: Types.ExtractReason, K>, RK>, error: Types.NarrowReason, K>, RK>) => Channel, orElse?: ((reason: Types.ExcludeReason, K>, RK>, error: Types.OmitReason, K>, RK>) => Channel) | undefined): (self: Channel) => Channel, (OutElem2 extends Types.unassigned ? OutErr : Types.ExcludeTag) | OutErr1 | OutErr2, OutDone | OutDone1 | OutDone2, InElem & InElem1 & InElem2, InErr & InErr1 & InErr2, InDone & InDone1 & InDone2, Env | Env1 | Env2>; /** * Catches a specific reason within a tagged error. * * @example * ```ts * import { Channel, Data } from "effect" * * class RateLimitError extends Data.TaggedError("RateLimitError")<{ * retryAfter: number * }> {} * * class QuotaExceededError extends Data.TaggedError("QuotaExceededError")<{ * limit: number * }> {} * * class AiError extends Data.TaggedError("AiError")<{ * reason: RateLimitError | QuotaExceededError * }> {} * * const channel = Channel.fail( * new AiError({ reason: new RateLimitError({ retryAfter: 60 }) }) * ) * * const recovered = channel.pipe( * Channel.catchReason("AiError", "RateLimitError", (reason) => * Channel.succeed(`retry: ${reason.retryAfter}`) * ) * ) * ``` * * @since 4.0.0 * @category Error handling */ , RK extends Types.ReasonTags, K>>, OutElem1, OutErr1, OutDone1, InElem1, InErr1, InDone1, Env1, OutElem2 = Types.unassigned, OutErr2 = never, OutDone2 = never, InElem2 = unknown, InErr2 = unknown, InDone2 = unknown, Env2 = never>(self: Channel, errorTag: K, reasonTag: RK, f: (reason: Types.ExtractReason, K>, RK>, error: Types.NarrowReason, K>, RK>) => Channel, orElse?: ((reason: Types.ExcludeReason, K>, RK>, error: Types.OmitReason, K>, RK>) => Channel) | undefined): Channel, (OutElem2 extends Types.unassigned ? OutErr : Types.ExcludeTag) | OutErr1 | OutErr2, OutDone | OutDone1 | OutDone2, InElem & InElem1 & InElem2, InErr & InErr1 & InErr2, InDone & InDone1 & InDone2, Env | Env1 | Env2>; }; /** * Catches multiple reasons within a tagged error using an object of handlers. * * @since 4.0.0 * @category Error handling */ export declare const catchReasons: { /** * Catches multiple reasons within a tagged error using an object of handlers. * * @since 4.0.0 * @category Error handling */ , OutErr, Cases extends { [RK in Types.ReasonTags, K>>]+?: (reason: Types.ExtractReason, K>, RK>, error: Types.NarrowReason, K>, RK>) => Channel; }, OutElem2 = Types.unassigned, OutErr2 = never, OutDone2 = never, InElem2 = unknown, InErr2 = unknown, InDone2 = unknown, Env2 = never>(errorTag: K, cases: Cases, orElse?: ((reason: Types.ExcludeReason, K>, Extract>, error: Types.OmitReason, K>, Extract>) => Channel) | undefined): (self: Channel) => Channel | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? OutElem1 : never; }[keyof Cases], (OutElem2 extends Types.unassigned ? OutErr : Types.ExcludeTag) | OutErr2 | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? OutErr1 : never; }[keyof Cases], OutDone | OutDone2 | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? OutDone1 : never; }[keyof Cases], InElem & InElem2 & { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? InElem1 : never; }[keyof Cases], InErr & InErr2 & { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? InErr1 : never; }[keyof Cases], InDone & InDone2 & { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? InDone1 : never; }[keyof Cases], Env | Env2 | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? Env1 : never; }[keyof Cases]>; /** * Catches multiple reasons within a tagged error using an object of handlers. * * @since 4.0.0 * @category Error handling */ , Cases extends { [RK in Types.ReasonTags>]+?: (reason: Types.ExtractReason, RK>, error: Types.NarrowReason, RK>) => Channel; }, OutElem2 = Types.unassigned, OutErr2 = never, OutDone2 = never, InElem2 = unknown, InErr2 = unknown, InDone2 = unknown, Env2 = never>(self: Channel, errorTag: K, cases: Cases, orElse?: ((reason: Types.ExcludeReason, K>, Extract>, error: Types.OmitReason, K>, Extract>) => Channel) | undefined): Channel | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? OutElem1 : never; }[keyof Cases], (OutElem2 extends Types.unassigned ? OutErr : Types.ExcludeTag) | OutErr2 | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? OutErr1 : never; }[keyof Cases], OutDone | OutDone2 | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? OutDone1 : never; }[keyof Cases], InElem & InElem2 & { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? InElem1 : never; }[keyof Cases], InErr & InErr2 & { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? InErr1 : never; }[keyof Cases], InDone & InDone2 & { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? InDone1 : never; }[keyof Cases], Env | Env2 | { [RK in keyof Cases]: Cases[RK] extends (...args: Array) => Channel ? Env1 : never; }[keyof Cases]>; }; /** * Promotes nested reason errors into the channel error, replacing the parent error. * * @example * ```ts * import { Channel, Data } from "effect" * * class RateLimitError extends Data.TaggedError("RateLimitError")<{ * retryAfter: number * }> {} * * class QuotaExceededError extends Data.TaggedError("QuotaExceededError")<{ * limit: number * }> {} * * class AiError extends Data.TaggedError("AiError")<{ * reason: RateLimitError | QuotaExceededError * }> {} * * const channel = Channel.fail( * new AiError({ reason: new RateLimitError({ retryAfter: 60 }) }) * ) * * const unwrapped = channel.pipe(Channel.unwrapReason("AiError")) * ``` * * @since 4.0.0 * @category Error handling */ export declare const unwrapReason: { /** * Promotes nested reason errors into the channel error, replacing the parent error. * * @example * ```ts * import { Channel, Data } from "effect" * * class RateLimitError extends Data.TaggedError("RateLimitError")<{ * retryAfter: number * }> {} * * class QuotaExceededError extends Data.TaggedError("QuotaExceededError")<{ * limit: number * }> {} * * class AiError extends Data.TaggedError("AiError")<{ * reason: RateLimitError | QuotaExceededError * }> {} * * const channel = Channel.fail( * new AiError({ reason: new RateLimitError({ retryAfter: 60 }) }) * ) * * const unwrapped = channel.pipe(Channel.unwrapReason("AiError")) * ``` * * @since 4.0.0 * @category Error handling */ , OutErr>(errorTag: K): (self: Channel) => Channel | Types.ReasonOf>, OutDone, InElem, InErr, InDone, Env>; /** * Promotes nested reason errors into the channel error, replacing the parent error. * * @example * ```ts * import { Channel, Data } from "effect" * * class RateLimitError extends Data.TaggedError("RateLimitError")<{ * retryAfter: number * }> {} * * class QuotaExceededError extends Data.TaggedError("QuotaExceededError")<{ * limit: number * }> {} * * class AiError extends Data.TaggedError("AiError")<{ * reason: RateLimitError | QuotaExceededError * }> {} * * const channel = Channel.fail( * new AiError({ reason: new RateLimitError({ retryAfter: 60 }) }) * ) * * const unwrapped = channel.pipe(Channel.unwrapReason("AiError")) * ``` * * @since 4.0.0 * @category Error handling */ >(self: Channel, errorTag: K): Channel | Types.ReasonOf>, OutDone, InElem, InErr, InDone, Env>; }; /** * Returns a new channel, which is the same as this one, except the failure * value of the returned channel is created by applying the specified function * to the failure value of this channel. * * @since 2.0.0 * @category Error handling */ export declare const mapError: { /** * Returns a new channel, which is the same as this one, except the failure * value of the returned channel is created by applying the specified function * to the failure value of this channel. * * @since 2.0.0 * @category Error handling */ (f: (err: OutErr) => OutErr2): (self: Channel) => Channel; /** * Returns a new channel, which is the same as this one, except the failure * value of the returned channel is created by applying the specified function * to the failure value of this channel. * * @since 2.0.0 * @category Error handling */ (self: Channel, f: (err: OutErr) => OutErr2): Channel; }; /** * Converts all errors in the channel to defects (unrecoverable failures). * This is useful when you want to treat errors as programming errors. * * @example * ```ts * import { Channel, Data } from "effect" * * class ValidationError extends Data.TaggedError("ValidationError")<{ * readonly field: string * }> {} * * // Create a channel that might fail * const failingChannel = Channel.fail(new ValidationError({ field: "email" })) * * // Convert failures to defects * const fatalChannel = Channel.orDie(failingChannel) * * // Any failure will now become a defect (uncaught exception) * ``` * * @since 4.0.0 * @category Error handling */ export declare const orDie: (self: Channel) => Channel; /** * Ignores all errors in the channel, converting them to an empty channel. * * Use the `log` option to emit the full {@link Cause} when the channel fails. * * @since 4.0.0 * @category Error handling */ export declare const ignore: | { readonly log?: boolean | Severity | undefined; } | undefined = { readonly log?: boolean | Severity | undefined; }>(selfOrOptions: Arg, options?: { readonly log?: boolean | Severity | undefined; } | undefined) => [Arg] extends [ Channel ] ? Channel : (self: Channel) => Channel; /** * Ignores all errors in the channel including defects, converting them to an empty channel. * * Use the `log` option to emit the full {@link Cause} when the channel fails. * * @since 4.0.0 * @category Error handling */ export declare const ignoreCause: | { readonly log?: boolean | Severity | undefined; } | undefined = { readonly log?: boolean | Severity | undefined; }>(selfOrOptions: Arg, options?: { readonly log?: boolean | Severity | undefined; } | undefined) => [Arg] extends [ Channel ] ? Channel : (self: Channel) => Channel; /** * Returns a new channel that retries this channel according to the specified * schedule whenever it fails. * * @since 4.0.0 * @category utils */ export declare const retry: { /** * Returns a new channel that retries this channel according to the specified * schedule whenever it fails. * * @since 4.0.0 * @category utils */ (schedule: Schedule.Schedule, SE, SR> | (($: (_: Schedule.Schedule, SE, SR>) => Schedule.Schedule) => Schedule.Schedule, SE, SR>)): (self: Channel) => Channel; /** * Returns a new channel that retries this channel according to the specified * schedule whenever it fails. * * @since 4.0.0 * @category utils */ (self: Channel, schedule: Schedule.Schedule | (($: (_: Schedule.Schedule, SE, SR>) => Schedule.Schedule) => Schedule.Schedule, SE, SR>)): Channel; }; /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the output values of this channel. The result is a channel that will first * perform the functions of this channel, before performing the functions of * the created channel (including yielding its terminal value). * * @example * ```ts * import { Channel, Data } from "effect" * * class SwitchError extends Data.TaggedError("SwitchError")<{ * readonly reason: string * }> {} * * // Create a channel that outputs numbers * const numberChannel = Channel.fromIterable([1, 2, 3]) * * // Switch to new channels based on each value * const switchedChannel = Channel.switchMap( * numberChannel, * (n) => Channel.fromIterable([`value-${n}`]) * ) * * // Outputs: "value-1", "value-2", "value-3" * ``` * * @since 2.0.0 * @category sequencing */ export declare const switchMap: { /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the output values of this channel. The result is a channel that will first * perform the functions of this channel, before performing the functions of * the created channel (including yielding its terminal value). * * @example * ```ts * import { Channel, Data } from "effect" * * class SwitchError extends Data.TaggedError("SwitchError")<{ * readonly reason: string * }> {} * * // Create a channel that outputs numbers * const numberChannel = Channel.fromIterable([1, 2, 3]) * * // Switch to new channels based on each value * const switchedChannel = Channel.switchMap( * numberChannel, * (n) => Channel.fromIterable([`value-${n}`]) * ) * * // Outputs: "value-1", "value-2", "value-3" * ``` * * @since 2.0.0 * @category sequencing */ (f: (d: OutElem) => Channel, options?: { readonly concurrency?: number | "unbounded" | undefined; readonly bufferSize?: number | undefined; }): (self: Channel) => Channel; /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the output values of this channel. The result is a channel that will first * perform the functions of this channel, before performing the functions of * the created channel (including yielding its terminal value). * * @example * ```ts * import { Channel, Data } from "effect" * * class SwitchError extends Data.TaggedError("SwitchError")<{ * readonly reason: string * }> {} * * // Create a channel that outputs numbers * const numberChannel = Channel.fromIterable([1, 2, 3]) * * // Switch to new channels based on each value * const switchedChannel = Channel.switchMap( * numberChannel, * (n) => Channel.fromIterable([`value-${n}`]) * ) * * // Outputs: "value-1", "value-2", "value-3" * ``` * * @since 2.0.0 * @category sequencing */ (self: Channel, f: (d: OutElem) => Channel, options?: { readonly concurrency?: number | "unbounded" | undefined; readonly bufferSize?: number | undefined; }): Channel; }; /** * Merges multiple channels with specified concurrency and buffering options. * * @example * ```ts * import { Channel, Data } from "effect" * * class MergeAllError extends Data.TaggedError("MergeAllError")<{ * readonly reason: string * }> {} * * // Create channels that output other channels * const nestedChannels = Channel.fromIterable([ * Channel.fromIterable([1, 2]), * Channel.fromIterable([3, 4]), * Channel.fromIterable([5, 6]) * ]) * * // Merge all channels with bounded concurrency * const mergedChannel = Channel.mergeAll({ * concurrency: 2, * bufferSize: 16 * })(nestedChannels) * * // Outputs: 1, 2, 3, 4, 5, 6 (order may vary due to concurrency) * ``` * * @since 2.0.0 * @category utils */ export declare const mergeAll: { /** * Merges multiple channels with specified concurrency and buffering options. * * @example * ```ts * import { Channel, Data } from "effect" * * class MergeAllError extends Data.TaggedError("MergeAllError")<{ * readonly reason: string * }> {} * * // Create channels that output other channels * const nestedChannels = Channel.fromIterable([ * Channel.fromIterable([1, 2]), * Channel.fromIterable([3, 4]), * Channel.fromIterable([5, 6]) * ]) * * // Merge all channels with bounded concurrency * const mergedChannel = Channel.mergeAll({ * concurrency: 2, * bufferSize: 16 * })(nestedChannels) * * // Outputs: 1, 2, 3, 4, 5, 6 (order may vary due to concurrency) * ``` * * @since 2.0.0 * @category utils */ (options: { readonly concurrency: number | "unbounded"; readonly bufferSize?: number | undefined; readonly switch?: boolean | undefined; }): (channels: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>) => Channel; /** * Merges multiple channels with specified concurrency and buffering options. * * @example * ```ts * import { Channel, Data } from "effect" * * class MergeAllError extends Data.TaggedError("MergeAllError")<{ * readonly reason: string * }> {} * * // Create channels that output other channels * const nestedChannels = Channel.fromIterable([ * Channel.fromIterable([1, 2]), * Channel.fromIterable([3, 4]), * Channel.fromIterable([5, 6]) * ]) * * // Merge all channels with bounded concurrency * const mergedChannel = Channel.mergeAll({ * concurrency: 2, * bufferSize: 16 * })(nestedChannels) * * // Outputs: 1, 2, 3, 4, 5, 6 (order may vary due to concurrency) * ``` * * @since 2.0.0 * @category utils */ (channels: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>, options: { readonly concurrency: number | "unbounded"; readonly bufferSize?: number | undefined; readonly switch?: boolean | undefined; }): Channel; }; /** * Represents strategies for halting merged channels when one completes or fails. * * @example * ```ts * import type { Channel } from "effect" * * // Different halt strategies for channel merging * const leftFirst: Channel.HaltStrategy = "left" // Stop when left channel halts * const rightFirst: Channel.HaltStrategy = "right" // Stop when right channel halts * const both: Channel.HaltStrategy = "both" // Stop when both channels halt * const either: Channel.HaltStrategy = "either" // Stop when either channel halts * ``` * * @since 2.0.0 * @category models */ export type HaltStrategy = "left" | "right" | "both" | "either"; /** * Returns a new channel, which is the merge of this channel and the specified * channel. * * @example * ```ts * import { Channel, Data } from "effect" * * class MergeError extends Data.TaggedError("MergeError")<{ * readonly source: string * }> {} * * // Create two channels * const leftChannel = Channel.fromIterable([1, 2, 3]) * const rightChannel = Channel.fromIterable(["a", "b", "c"]) * * // Merge them with "either" halt strategy * const mergedChannel = Channel.merge(leftChannel, rightChannel, { * haltStrategy: "either" * }) * * // Outputs elements from both channels concurrently * // Order may vary: 1, "a", 2, "b", 3, "c" * ``` * * @since 2.0.0 * @category utils */ export declare const merge: { /** * Returns a new channel, which is the merge of this channel and the specified * channel. * * @example * ```ts * import { Channel, Data } from "effect" * * class MergeError extends Data.TaggedError("MergeError")<{ * readonly source: string * }> {} * * // Create two channels * const leftChannel = Channel.fromIterable([1, 2, 3]) * const rightChannel = Channel.fromIterable(["a", "b", "c"]) * * // Merge them with "either" halt strategy * const mergedChannel = Channel.merge(leftChannel, rightChannel, { * haltStrategy: "either" * }) * * // Outputs elements from both channels concurrently * // Order may vary: 1, "a", 2, "b", 3, "c" * ``` * * @since 2.0.0 * @category utils */ (right: Channel, options?: { readonly haltStrategy?: HaltStrategy | undefined; } | undefined): (left: Channel) => Channel; /** * Returns a new channel, which is the merge of this channel and the specified * channel. * * @example * ```ts * import { Channel, Data } from "effect" * * class MergeError extends Data.TaggedError("MergeError")<{ * readonly source: string * }> {} * * // Create two channels * const leftChannel = Channel.fromIterable([1, 2, 3]) * const rightChannel = Channel.fromIterable(["a", "b", "c"]) * * // Merge them with "either" halt strategy * const mergedChannel = Channel.merge(leftChannel, rightChannel, { * haltStrategy: "either" * }) * * // Outputs elements from both channels concurrently * // Order may vary: 1, "a", 2, "b", 3, "c" * ``` * * @since 2.0.0 * @category utils */ (left: Channel, right: Channel, options?: { readonly haltStrategy?: HaltStrategy | undefined; } | undefined): Channel; }; /** * @since 4.0.0 * @category utils */ export declare const mergeEffect: { /** * @since 4.0.0 * @category utils */ (effect: Effect.Effect): (self: Channel) => Channel; /** * @since 4.0.0 * @category utils */ (self: Channel, effect: Effect.Effect): Channel; }; /** * Splits upstream string chunks into lines, recognizing `\n`, `\r\n`, and * standalone `\r` as line terminators. The behavior matches * `String.linesIterator` regardless of how the input is chunked. * * A line terminator at the very end of the stream does **not** produce a * trailing empty line (consistent with `String.linesIterator`). Conversely, * if the stream ends without a terminator the final partial line is still * emitted. * * **Example** * * ```ts * import { Effect, Stream } from "effect" * * Effect.runPromise(Effect.gen(function*() { * const result = yield* Stream.runCollect( * Stream.splitLines(Stream.make("hel", "lo\r\nwor", "ld\n")) * ) * console.log(result) * // [ 'hello', 'world' ] * })) * ``` * * @since 2.0.0 * @category String manipulation */ export declare const splitLines: () => Channel, Err, Done, Arr.NonEmptyReadonlyArray, Err, Done>; /** * @since 4.0.0 * @category String manipulation */ export declare const decodeText: (encoding?: string, options?: TextDecoderOptions) => Channel, Err, Done, Arr.NonEmptyReadonlyArray, Err, Done>; /** * @since 4.0.0 * @category String manipulation */ export declare const encodeText: () => Channel, Err, Done, Arr.NonEmptyReadonlyArray, Err, Done>; /** * Returns a new channel that pipes the output of this channel into the * specified channel. The returned channel has the input type of this channel, * and the output type of the specified channel, terminating with the value of * the specified channel. * * @example * ```ts * import { Channel, Data } from "effect" * * class PipeError extends Data.TaggedError("PipeError")<{ * readonly stage: string * }> {} * * // Create source and transform channels * const sourceChannel = Channel.fromIterable([1, 2, 3]) * const transformChannel = Channel.map(sourceChannel, (n: number) => n * 2) * * // Pipe the source into the transform * const pipedChannel = Channel.pipeTo(sourceChannel, transformChannel) * * // Outputs: 2, 4, 6 * ``` * * @since 2.0.0 * @category utils */ export declare const pipeTo: { /** * Returns a new channel that pipes the output of this channel into the * specified channel. The returned channel has the input type of this channel, * and the output type of the specified channel, terminating with the value of * the specified channel. * * @example * ```ts * import { Channel, Data } from "effect" * * class PipeError extends Data.TaggedError("PipeError")<{ * readonly stage: string * }> {} * * // Create source and transform channels * const sourceChannel = Channel.fromIterable([1, 2, 3]) * const transformChannel = Channel.map(sourceChannel, (n: number) => n * 2) * * // Pipe the source into the transform * const pipedChannel = Channel.pipeTo(sourceChannel, transformChannel) * * // Outputs: 2, 4, 6 * ``` * * @since 2.0.0 * @category utils */ (that: Channel): (self: Channel) => Channel; /** * Returns a new channel that pipes the output of this channel into the * specified channel. The returned channel has the input type of this channel, * and the output type of the specified channel, terminating with the value of * the specified channel. * * @example * ```ts * import { Channel, Data } from "effect" * * class PipeError extends Data.TaggedError("PipeError")<{ * readonly stage: string * }> {} * * // Create source and transform channels * const sourceChannel = Channel.fromIterable([1, 2, 3]) * const transformChannel = Channel.map(sourceChannel, (n: number) => n * 2) * * // Pipe the source into the transform * const pipedChannel = Channel.pipeTo(sourceChannel, transformChannel) * * // Outputs: 2, 4, 6 * ``` * * @since 2.0.0 * @category utils */ (self: Channel, that: Channel): Channel; }; /** * Returns a new channel that pipes the output of this channel into the * specified channel and preserves this channel's failures without providing * them to the other channel for observation. * * @example * ```ts * import { Channel, Data } from "effect" * * class SourceError extends Data.TaggedError("SourceError")<{ * readonly code: number * }> {} * * // Create a failing source channel * const failingSource = Channel.fail(new SourceError({ code: 404 })) * const safeTransform = Channel.succeed("transformed") * * // Pipe while preserving source failures * const safePipedChannel = Channel.pipeToOrFail(failingSource, safeTransform) * * // Source errors are preserved and not sent to transform channel * ``` * * @since 2.0.0 * @category utils */ export declare const pipeToOrFail: { /** * Returns a new channel that pipes the output of this channel into the * specified channel and preserves this channel's failures without providing * them to the other channel for observation. * * @example * ```ts * import { Channel, Data } from "effect" * * class SourceError extends Data.TaggedError("SourceError")<{ * readonly code: number * }> {} * * // Create a failing source channel * const failingSource = Channel.fail(new SourceError({ code: 404 })) * const safeTransform = Channel.succeed("transformed") * * // Pipe while preserving source failures * const safePipedChannel = Channel.pipeToOrFail(failingSource, safeTransform) * * // Source errors are preserved and not sent to transform channel * ``` * * @since 2.0.0 * @category utils */ (that: Channel): (self: Channel) => Channel; /** * Returns a new channel that pipes the output of this channel into the * specified channel and preserves this channel's failures without providing * them to the other channel for observation. * * @example * ```ts * import { Channel, Data } from "effect" * * class SourceError extends Data.TaggedError("SourceError")<{ * readonly code: number * }> {} * * // Create a failing source channel * const failingSource = Channel.fail(new SourceError({ code: 404 })) * const safeTransform = Channel.succeed("transformed") * * // Pipe while preserving source failures * const safePipedChannel = Channel.pipeToOrFail(failingSource, safeTransform) * * // Source errors are preserved and not sent to transform channel * ``` * * @since 2.0.0 * @category utils */ (self: Channel, that: Channel): Channel; }; /** * Constructs a `Channel` from a scoped effect that will result in a * `Channel` if successful. * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class UnwrapError extends Data.TaggedError("UnwrapError")<{ * readonly reason: string * }> {} * * // Create an effect that produces a channel * const channelEffect = Effect.succeed( * Channel.fromIterable([1, 2, 3]) * ) * * // Unwrap the effect to get the channel * const unwrappedChannel = Channel.unwrap(channelEffect) * * // The resulting channel outputs: 1, 2, 3 * ``` * * @since 2.0.0 * @category constructors */ export declare const unwrap: (channel: Effect.Effect, E, R>) => Channel | R2>; /** * @since 2.0.0 * @category utils */ export declare const scoped: (self: Channel) => Channel>; /** * Returns a new channel which embeds the given input handler into a Channel. * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class EmbedError extends Data.TaggedError("EmbedError")<{ * readonly stage: string * }> {} * * // Create a base channel * const baseChannel = Channel.fromIterable([1, 2, 3]) * * // Embed input handling - simplified example * const embeddedChannel = Channel.embedInput( * baseChannel, * (_upstream) => Effect.void * ) * ``` * * @since 2.0.0 * @category utils */ export declare const embedInput: { /** * Returns a new channel which embeds the given input handler into a Channel. * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class EmbedError extends Data.TaggedError("EmbedError")<{ * readonly stage: string * }> {} * * // Create a base channel * const baseChannel = Channel.fromIterable([1, 2, 3]) * * // Embed input handling - simplified example * const embeddedChannel = Channel.embedInput( * baseChannel, * (_upstream) => Effect.void * ) * ``` * * @since 2.0.0 * @category utils */ (input: (upstream: Pull.Pull) => Effect.Effect): (self: Channel) => Channel; /** * Returns a new channel which embeds the given input handler into a Channel. * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class EmbedError extends Data.TaggedError("EmbedError")<{ * readonly stage: string * }> {} * * // Create a base channel * const baseChannel = Channel.fromIterable([1, 2, 3]) * * // Embed input handling - simplified example * const embeddedChannel = Channel.embedInput( * baseChannel, * (_upstream) => Effect.void * ) * ``` * * @since 2.0.0 * @category utils */ (self: Channel, input: (upstream: Pull.Pull) => Effect.Effect): Channel; }; /** * Allows a faster producer to progress independently of a slower consumer by * buffering up to `capacity` elements in a queue. * * @since 2.0.0 * @category Buffering */ export declare const buffer: { /** * Allows a faster producer to progress independently of a slower consumer by * buffering up to `capacity` elements in a queue. * * @since 2.0.0 * @category Buffering */ (options: { readonly capacity: "unbounded"; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; }): (self: Channel) => Channel; /** * Allows a faster producer to progress independently of a slower consumer by * buffering up to `capacity` elements in a queue. * * @since 2.0.0 * @category Buffering */ (self: Channel, options: { readonly capacity: "unbounded"; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; }): Channel; }; /** * Allows a faster producer to progress independently of a slower consumer by * buffering up to `capacity` elements in a queue. * * @since 2.0.0 * @category Buffering */ export declare const bufferArray: { /** * Allows a faster producer to progress independently of a slower consumer by * buffering up to `capacity` elements in a queue. * * @since 2.0.0 * @category Buffering */ (options: { readonly capacity: "unbounded"; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; }): (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>) => Channel, OutErr, OutDone, InElem, InErr, InDone, Env>; /** * Allows a faster producer to progress independently of a slower consumer by * buffering up to `capacity` elements in a queue. * * @since 2.0.0 * @category Buffering */ (self: Channel, OutErr, OutDone, InElem, InErr, InDone, Env>, options: { readonly capacity: "unbounded"; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; }): Channel, OutErr, OutDone, InElem, InErr, InDone, Env>; }; /** * Returns a new channel, which is the same as this one, except it will be * interrupted when the specified effect completes. If the effect completes * successfully before the underlying channel is done, then the returned * channel will yield the success value of the effect as its terminal value. * On the other hand, if the underlying channel finishes first, then the * returned channel will yield the success value of the underlying channel as * its terminal value. * * @since 2.0.0 * @category utils */ export declare const interruptWhen: { /** * Returns a new channel, which is the same as this one, except it will be * interrupted when the specified effect completes. If the effect completes * successfully before the underlying channel is done, then the returned * channel will yield the success value of the effect as its terminal value. * On the other hand, if the underlying channel finishes first, then the * returned channel will yield the success value of the underlying channel as * its terminal value. * * @since 2.0.0 * @category utils */ (effect: Effect.Effect): (self: Channel) => Channel; /** * Returns a new channel, which is the same as this one, except it will be * interrupted when the specified effect completes. If the effect completes * successfully before the underlying channel is done, then the returned * channel will yield the success value of the effect as its terminal value. * On the other hand, if the underlying channel finishes first, then the * returned channel will yield the success value of the underlying channel as * its terminal value. * * @since 2.0.0 * @category utils */ (self: Channel, effect: Effect.Effect): Channel; }; /** * @since 4.0.0 * @category utils */ export declare const haltWhen: { /** * @since 4.0.0 * @category utils */ (effect: Effect.Effect): (self: Channel) => Channel; /** * @since 4.0.0 * @category utils */ (self: Channel, effect: Effect.Effect): Channel; }; /** * @since 4.0.0 * @category utils */ export declare const onError: { /** * @since 4.0.0 * @category utils */ (finalizer: (cause: Cause.Cause) => Effect.Effect): (self: Channel) => Channel; /** * @since 4.0.0 * @category utils */ (self: Channel, finalizer: (cause: Cause.Cause) => Effect.Effect): Channel; }; /** * Returns a new channel with an attached finalizer. The finalizer is * guaranteed to be executed so long as the channel begins execution (and * regardless of whether or not it completes). * * @example * ```ts * import { Channel, Console, Data, Exit } from "effect" * * class ExitError extends Data.TaggedError("ExitError")<{ * readonly stage: string * }> {} * * // Create a channel * const dataChannel = Channel.fromIterable([1, 2, 3]) * * // Attach exit handler * const channelWithExit = Channel.onExit(dataChannel, (exit) => { * if (Exit.isSuccess(exit)) { * return Console.log(`Channel completed successfully with: ${exit.value}`) * } else { * return Console.log(`Channel failed with: ${exit.cause}`) * } * }) * ``` * * @since 4.0.0 * @category utils */ export declare const onExit: { /** * Returns a new channel with an attached finalizer. The finalizer is * guaranteed to be executed so long as the channel begins execution (and * regardless of whether or not it completes). * * @example * ```ts * import { Channel, Console, Data, Exit } from "effect" * * class ExitError extends Data.TaggedError("ExitError")<{ * readonly stage: string * }> {} * * // Create a channel * const dataChannel = Channel.fromIterable([1, 2, 3]) * * // Attach exit handler * const channelWithExit = Channel.onExit(dataChannel, (exit) => { * if (Exit.isSuccess(exit)) { * return Console.log(`Channel completed successfully with: ${exit.value}`) * } else { * return Console.log(`Channel failed with: ${exit.cause}`) * } * }) * ``` * * @since 4.0.0 * @category utils */ (finalizer: (e: Exit.Exit) => Effect.Effect): (self: Channel) => Channel; /** * Returns a new channel with an attached finalizer. The finalizer is * guaranteed to be executed so long as the channel begins execution (and * regardless of whether or not it completes). * * @example * ```ts * import { Channel, Console, Data, Exit } from "effect" * * class ExitError extends Data.TaggedError("ExitError")<{ * readonly stage: string * }> {} * * // Create a channel * const dataChannel = Channel.fromIterable([1, 2, 3]) * * // Attach exit handler * const channelWithExit = Channel.onExit(dataChannel, (exit) => { * if (Exit.isSuccess(exit)) { * return Console.log(`Channel completed successfully with: ${exit.value}`) * } else { * return Console.log(`Channel failed with: ${exit.cause}`) * } * }) * ``` * * @since 4.0.0 * @category utils */ (self: Channel, finalizer: (e: Exit.Exit) => Effect.Effect): Channel; }; /** * @since 4.0.0 * @category utils */ export declare const onStart: { /** * @since 4.0.0 * @category utils */ (onStart: Effect.Effect): (self: Channel) => Channel; /** * @since 4.0.0 * @category utils */ (self: Channel, onStart: Effect.Effect): Channel; }; /** * @since 4.0.0 * @category utils */ export declare const onFirst: { /** * @since 4.0.0 * @category utils */ (onFirst: (element: Types.NoInfer) => Effect.Effect): (self: Channel) => Channel; /** * @since 4.0.0 * @category utils */ (self: Channel, onFirst: (element: Types.NoInfer) => Effect.Effect): Channel; }; /** * @since 4.0.0 * @category utils */ export declare const onEnd: { /** * @since 4.0.0 * @category utils */ (onEnd: Effect.Effect): (self: Channel) => Channel; /** * @since 4.0.0 * @category utils */ (self: Channel, onEnd: Effect.Effect): Channel; }; /** * Returns a new channel with an attached finalizer. The finalizer is * guaranteed to be executed so long as the channel begins execution (and * regardless of whether or not it completes). * * @example * ```ts * import { Channel, Console, Data } from "effect" * * class EnsureError extends Data.TaggedError("EnsureError")<{ * readonly operation: string * }> {} * * // Create a channel * const dataChannel = Channel.fromIterable([1, 2, 3]) * * // Ensure cleanup always runs * const channelWithCleanup = Channel.ensuring( * dataChannel, * Console.log("Cleanup executed regardless of success or failure") * ) * ``` * * @since 2.0.0 * @category utils */ export declare const ensuring: { /** * Returns a new channel with an attached finalizer. The finalizer is * guaranteed to be executed so long as the channel begins execution (and * regardless of whether or not it completes). * * @example * ```ts * import { Channel, Console, Data } from "effect" * * class EnsureError extends Data.TaggedError("EnsureError")<{ * readonly operation: string * }> {} * * // Create a channel * const dataChannel = Channel.fromIterable([1, 2, 3]) * * // Ensure cleanup always runs * const channelWithCleanup = Channel.ensuring( * dataChannel, * Console.log("Cleanup executed regardless of success or failure") * ) * ``` * * @since 2.0.0 * @category utils */ (finalizer: Effect.Effect): (self: Channel) => Channel; /** * Returns a new channel with an attached finalizer. The finalizer is * guaranteed to be executed so long as the channel begins execution (and * regardless of whether or not it completes). * * @example * ```ts * import { Channel, Console, Data } from "effect" * * class EnsureError extends Data.TaggedError("EnsureError")<{ * readonly operation: string * }> {} * * // Create a channel * const dataChannel = Channel.fromIterable([1, 2, 3]) * * // Ensure cleanup always runs * const channelWithCleanup = Channel.ensuring( * dataChannel, * Console.log("Cleanup executed regardless of success or failure") * ) * ``` * * @since 2.0.0 * @category utils */ (self: Channel, finalizer: Effect.Effect): Channel; }; /** * Create a channel from the specified services. * * @since 2.0.0 * @category Services */ export declare const contextWith: (f: (context: Context.Context) => Channel) => Channel; /** * Provides a layer or context to the channel, removing the corresponding * service requirements. Use `options.local` to build the layer every time; by * default, layers are shared between provide calls. * * @since 4.0.0 * @category Services */ export declare const provideContext: { /** * Provides a layer or context to the channel, removing the corresponding * service requirements. Use `options.local` to build the layer every time; by * default, layers are shared between provide calls. * * @since 4.0.0 * @category Services */ (context: Context.Context): (self: Channel) => Channel>; /** * Provides a layer or context to the channel, removing the corresponding * service requirements. Use `options.local` to build the layer every time; by * default, layers are shared between provide calls. * * @since 4.0.0 * @category Services */ (self: Channel, context: Context.Context): Channel>; }; /** * @since 4.0.0 * @category Services */ export declare const provideService: { /** * @since 4.0.0 * @category Services */ (key: Context.Key, service: NoInfer): (self: Channel) => Channel>; /** * @since 4.0.0 * @category Services */ (self: Channel, key: Context.Key, service: NoInfer): Channel>; }; /** * @since 4.0.0 * @category Services */ export declare const provideServiceEffect: { /** * @since 4.0.0 * @category Services */ (key: Context.Key, service: Effect.Effect, ES, RS>): (self: Channel) => Channel | RS>; /** * @since 4.0.0 * @category Services */ (self: Channel, key: Context.Key, service: Effect.Effect, ES, RS>): Channel | RS>; }; /** * @since 4.0.0 * @category Services */ export declare const provide: { /** * @since 4.0.0 * @category Services */ (layer: Layer.Layer | Context.Context, options?: { readonly local?: boolean | undefined; } | undefined): (self: Channel) => Channel | R>; /** * @since 4.0.0 * @category Services */ (self: Channel, layer: Layer.Layer | Context.Context, options?: { readonly local?: boolean | undefined; } | undefined): Channel | R>; }; /** * @since 2.0.0 * @category Services */ export declare const updateContext: { /** * @since 2.0.0 * @category Services */ (f: (context: Context.Context) => Context.Context): (self: Channel) => Channel; /** * @since 2.0.0 * @category Services */ (self: Channel, f: (context: Context.Context) => Context.Context): Channel; }; /** * @since 2.0.0 * @category Services */ export declare const updateService: { /** * @since 2.0.0 * @category Services */ (key: Context.Key, f: (service: NoInfer) => S): (self: Channel) => Channel; /** * @since 2.0.0 * @category Services */ (self: Channel, service: Context.Key, f: (service: NoInfer) => S): Channel; }; /** * @since 4.0.0 * @category Tracing */ export declare const withSpan: { /** * @since 4.0.0 * @category Tracing */ (name: string, options?: SpanOptions): (self: Channel) => Channel>; /** * @since 4.0.0 * @category Tracing */ (self: Channel, name: string, options?: SpanOptions): Channel>; }; /** * @since 4.0.0 * @category Do notation */ export declare const Do: Channel<{}>; declare const let_: { (name: Exclude, f: (a: NoInfer) => B): (self: Channel) => Channel<{ [K in N | keyof OutElem]: K extends keyof OutElem ? OutElem[K] : B; }, OutErr, OutDone, InElem, InErr, InDone, R>; (self: Channel, name: Exclude, f: (a: NoInfer) => B): Channel<{ [K in N | keyof OutElem]: K extends keyof OutElem ? OutElem[K] : B; }, OutErr, OutDone, InElem, InErr, InDone, R>; }; export { /** * @since 4.0.0 * @category Do notation */ let_ as let }; /** * @since 4.0.0 * @category Do notation */ export declare const bind: { /** * @since 4.0.0 * @category Do notation */ (name: Exclude, f: (a: NoInfer) => Channel, options?: { readonly concurrency?: number | "unbounded" | undefined; readonly bufferSize?: number | undefined; }): (self: Channel) => Channel<{ [K in N | keyof OutElem]: K extends keyof OutElem ? OutElem[K] : B; }, OutErr2 | OutErr, OutDone, InElem & InElem2, InErr & InErr2, InDone & InDone2, Env2 | Env>; /** * @since 4.0.0 * @category Do notation */ (self: Channel, name: Exclude, f: (a: NoInfer) => Channel, options?: { readonly concurrency?: number | "unbounded" | undefined; readonly bufferSize?: number | undefined; }): Channel<{ [K in N | keyof OutElem]: K extends keyof OutElem ? OutElem[K] : B; }, OutErr2 | OutErr, OutDone, InElem & InElem2, InErr & InErr2, InDone & InDone2, Env2 | Env>; }; /** * @since 4.0.0 * @category Do notation */ export declare const bindTo: { /** * @since 4.0.0 * @category Do notation */ (name: N): (self: Channel) => Channel<{ [K in N]: OutElem; }, OutErr, OutDone, InElem, InErr, InDone, Env>; /** * @since 4.0.0 * @category Do notation */ (self: Channel, name: N): Channel<{ [K in N]: OutElem; }, OutErr, OutDone, InElem, InErr, InDone, Env>; }; /** * Runs a channel and counts the number of elements it outputs. * * @example * ```ts * import { Channel, Data } from "effect" * * class CountError extends Data.TaggedError("CountError")<{ * readonly reason: string * }> {} * * // Create a channel with multiple elements * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Count the elements * const countEffect = Channel.runCount(numbersChannel) * * // Effect.runSync(countEffect) // Returns: 5 * ``` * * @since 2.0.0 * @category execution */ export declare const runCount: (self: Channel) => Effect.Effect; /** * Runs a channel and discards all output elements, returning only the final result. * * @example * ```ts * import { Channel, Data } from "effect" * * class DrainError extends Data.TaggedError("DrainError")<{ * readonly stage: string * }> {} * * // Create a channel that outputs elements and completes with a result * const resultChannel = Channel.fromIterable([1, 2, 3]) * const completedChannel = Channel.concatWith( * resultChannel, * () => Channel.succeed("completed") * ) * * // Drain all elements and get only the final result * const drainEffect = Channel.runDrain(completedChannel) * * // Effect.runSync(drainEffect) // Returns: "completed" * ``` * * @since 2.0.0 * @category execution */ export declare const runDrain: (self: Channel) => Effect.Effect; /** * Runs a channel and applies an effect to each output element. * * @example * ```ts * import { Channel, Console, Data } from "effect" * * class ForEachError extends Data.TaggedError("ForEachError")<{ * readonly element: unknown * }> {} * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3]) * * // Run forEach to log each element * const forEachEffect = Channel.runForEach( * numbersChannel, * (n) => Console.log(`Processing: ${n}`) * ) * * // Logs: "Processing: 1", "Processing: 2", "Processing: 3" * ``` * * @since 2.0.0 * @category execution */ export declare const runForEach: { /** * Runs a channel and applies an effect to each output element. * * @example * ```ts * import { Channel, Console, Data } from "effect" * * class ForEachError extends Data.TaggedError("ForEachError")<{ * readonly element: unknown * }> {} * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3]) * * // Run forEach to log each element * const forEachEffect = Channel.runForEach( * numbersChannel, * (n) => Console.log(`Processing: ${n}`) * ) * * // Logs: "Processing: 1", "Processing: 2", "Processing: 3" * ``` * * @since 2.0.0 * @category execution */ (f: (o: OutElem) => Effect.Effect): (self: Channel) => Effect.Effect; /** * Runs a channel and applies an effect to each output element. * * @example * ```ts * import { Channel, Console, Data } from "effect" * * class ForEachError extends Data.TaggedError("ForEachError")<{ * readonly element: unknown * }> {} * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3]) * * // Run forEach to log each element * const forEachEffect = Channel.runForEach( * numbersChannel, * (n) => Console.log(`Processing: ${n}`) * ) * * // Logs: "Processing: 1", "Processing: 2", "Processing: 3" * ``` * * @since 2.0.0 * @category execution */ (self: Channel, f: (o: OutElem) => Effect.Effect): Effect.Effect; }; /** * @since 2.0.0 * @category execution */ export declare const runForEachWhile: { /** * @since 2.0.0 * @category execution */ (f: (o: OutElem) => Effect.Effect): (self: Channel) => Effect.Effect; /** * @since 2.0.0 * @category execution */ (self: Channel, f: (o: OutElem) => Effect.Effect): Effect.Effect; }; /** * Runs a channel and collects all output elements into an array. * * @example * ```ts * import { Channel, Data } from "effect" * * class CollectError extends Data.TaggedError("CollectError")<{ * readonly reason: string * }> {} * * // Create a channel with elements * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Collect all elements into an array * const collectEffect = Channel.runCollect(numbersChannel) * * // Effect.runSync(collectEffect) // Returns: [1, 2, 3, 4, 5] * ``` * * @since 2.0.0 * @category execution */ export declare const runCollect: (self: Channel) => Effect.Effect, OutErr, Env>; /** * Runs a channel and outputs the done value. * * @since 4.0.0 * @category execution */ export declare const runDone: (self: Channel) => Effect.Effect; /** * @since 2.0.0 * @category execution */ export declare const runHead: (self: Channel) => Effect.Effect, OutErr, Env>; /** * @since 2.0.0 * @category execution */ export declare const runLast: (self: Channel) => Effect.Effect, OutErr, Env>; /** * Runs a channel and folds over all output elements with an accumulator. * * @example * ```ts * import { Channel, Data } from "effect" * * class FoldError extends Data.TaggedError("FoldError")<{ * readonly operation: string * }> {} * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Fold to calculate sum * const sumEffect = Channel.runFold(numbersChannel, () => 0, (acc, n) => acc + n) * * // Effect.runSync(sumEffect) // Returns: 15 * ``` * * @since 2.0.0 * @category execution */ export declare const runFold: { /** * Runs a channel and folds over all output elements with an accumulator. * * @example * ```ts * import { Channel, Data } from "effect" * * class FoldError extends Data.TaggedError("FoldError")<{ * readonly operation: string * }> {} * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Fold to calculate sum * const sumEffect = Channel.runFold(numbersChannel, () => 0, (acc, n) => acc + n) * * // Effect.runSync(sumEffect) // Returns: 15 * ``` * * @since 2.0.0 * @category execution */ (initial: LazyArg, f: (acc: Z, o: OutElem) => Z): (self: Channel) => Effect.Effect; /** * Runs a channel and folds over all output elements with an accumulator. * * @example * ```ts * import { Channel, Data } from "effect" * * class FoldError extends Data.TaggedError("FoldError")<{ * readonly operation: string * }> {} * * // Create a channel with numbers * const numbersChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Fold to calculate sum * const sumEffect = Channel.runFold(numbersChannel, () => 0, (acc, n) => acc + n) * * // Effect.runSync(sumEffect) // Returns: 15 * ``` * * @since 2.0.0 * @category execution */ (self: Channel, initial: LazyArg, f: (acc: Z, o: OutElem) => Z): Effect.Effect; }; /** * @since 2.0.0 * @category execution */ export declare const runFoldEffect: { /** * @since 2.0.0 * @category execution */ (initial: LazyArg, f: (acc: Z, o: OutElem) => Effect.Effect): (self: Channel) => Effect.Effect; /** * @since 2.0.0 * @category execution */ (self: Channel, initial: LazyArg, f: (acc: Z, o: OutElem) => Effect.Effect): Effect.Effect; }; /** * Converts a channel to a Pull data structure for low-level consumption. * * @example * ```ts * import { Channel, Data, Effect } from "effect" * * class PullError extends Data.TaggedError("PullError")<{ * readonly step: string * }> {} * * // Create a channel * const numbersChannel = Channel.fromIterable([1, 2, 3]) * * // Convert to Pull within a scope * const pullEffect = Effect.scoped( * Channel.toPull(numbersChannel) * ) * * // Use the Pull to manually consume elements * ``` * * @since 2.0.0 * @category Destructors */ export declare const toPull: (self: Channel) => Effect.Effect, never, Env | Scope.Scope>; /** * Converts a channel to a Pull within an existing scope. * * @example * ```ts * import { Channel, Data, Effect, Scope } from "effect" * * class ScopedPullError extends Data.TaggedError("ScopedPullError")<{ * readonly reason: string * }> {} * * // Create a channel * const numbersChannel = Channel.fromIterable([1, 2, 3]) * * // Convert to Pull with explicit scope * const scopedPullEffect = Effect.gen(function*() { * const scope = yield* Scope.make() * const pull = yield* Channel.toPullScoped(numbersChannel, scope) * return pull * }) * ``` * * @since 4.0.0 * @category Destructors */ export declare const toPullScoped: (self: Channel, scope: Scope.Scope) => Effect.Effect, never, Env>; /** * @since 4.0.0 * @category Destructors */ export declare const runIntoQueue: { /** * @since 4.0.0 * @category Destructors */ (queue: Queue.Queue): (self: Channel) => Effect.Effect; /** * @since 4.0.0 * @category Destructors */ (self: Channel, queue: Queue.Queue): Effect.Effect; }; /** * @since 4.0.0 * @category Destructors */ export declare const runIntoQueueArray: { /** * @since 4.0.0 * @category Destructors */ (queue: Queue.Queue): (self: Channel, OutErr, OutDone, unknown, unknown, unknown, Env>) => Effect.Effect; /** * @since 4.0.0 * @category Destructors */ (self: Channel, OutErr, OutDone, unknown, unknown, unknown, Env>, queue: Queue.Queue): Effect.Effect; }; /** * Converts a channel to a queue for concurrent consumption. * * @example * ```ts * import { Channel, Data } from "effect" * * class QueueError extends Data.TaggedError("QueueError")<{ * readonly operation: string * }> {} * * // Create a channel with data * const dataChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Convert to queue for concurrent processing * const queueEffect = Channel.toQueue(dataChannel, { capacity: 32 }) * * // The queue can be used for concurrent consumption * // Multiple consumers can read from the queue * ``` * * @since 4.0.0 * @category Destructors */ export declare const toQueue: { /** * Converts a channel to a queue for concurrent consumption. * * @example * ```ts * import { Channel, Data } from "effect" * * class QueueError extends Data.TaggedError("QueueError")<{ * readonly operation: string * }> {} * * // Create a channel with data * const dataChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Convert to queue for concurrent processing * const queueEffect = Channel.toQueue(dataChannel, { capacity: 32 }) * * // The queue can be used for concurrent consumption * // Multiple consumers can read from the queue * ``` * * @since 4.0.0 * @category Destructors */ (options: { readonly capacity: "unbounded"; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; }): (self: Channel) => Effect.Effect, never, Env | Scope.Scope>; /** * Converts a channel to a queue for concurrent consumption. * * @example * ```ts * import { Channel, Data } from "effect" * * class QueueError extends Data.TaggedError("QueueError")<{ * readonly operation: string * }> {} * * // Create a channel with data * const dataChannel = Channel.fromIterable([1, 2, 3, 4, 5]) * * // Convert to queue for concurrent processing * const queueEffect = Channel.toQueue(dataChannel, { capacity: 32 }) * * // The queue can be used for concurrent consumption * // Multiple consumers can read from the queue * ``` * * @since 4.0.0 * @category Destructors */ (self: Channel, options: { readonly capacity: "unbounded"; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; }): Effect.Effect, never, Env | Scope.Scope>; }; /** * @since 4.0.0 * @category Destructors */ export declare const toQueueArray: { /** * @since 4.0.0 * @category Destructors */ (options: { readonly capacity: "unbounded"; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; }): (self: Channel, OutErr, OutDone, unknown, unknown, unknown, Env>) => Effect.Effect, never, Env | Scope.Scope>; /** * @since 4.0.0 * @category Destructors */ (self: Channel, OutErr, OutDone, unknown, unknown, unknown, Env>, options: { readonly capacity: "unbounded"; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; }): Effect.Effect, never, Env | Scope.Scope>; }; /** * Converts a channel to a PubSub for concurrent consumption. * * `shutdownOnEnd` indicates whether the PubSub should be shut down when the * channel ends. By default this is `true`. * * @since 4.0.0 * @category Destructors */ export declare const toPubSub: { /** * Converts a channel to a PubSub for concurrent consumption. * * `shutdownOnEnd` indicates whether the PubSub should be shut down when the * channel ends. By default this is `true`. * * @since 4.0.0 * @category Destructors */ (options: { readonly capacity: "unbounded"; readonly replay?: number | undefined; readonly shutdownOnEnd?: boolean | undefined; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; readonly replay?: number | undefined; readonly shutdownOnEnd?: boolean | undefined; }): (self: Channel) => Effect.Effect, never, Env | Scope.Scope>; /** * Converts a channel to a PubSub for concurrent consumption. * * `shutdownOnEnd` indicates whether the PubSub should be shut down when the * channel ends. By default this is `true`. * * @since 4.0.0 * @category Destructors */ (self: Channel, options: { readonly capacity: "unbounded"; readonly replay?: number | undefined; readonly shutdownOnEnd?: boolean | undefined; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; readonly replay?: number | undefined; readonly shutdownOnEnd?: boolean | undefined; }): Effect.Effect, never, Env | Scope.Scope>; }; /** * @since 4.0.0 * @category Destructors */ export declare const runIntoPubSub: { /** * @since 4.0.0 * @category Destructors */ (pubsub: PubSub.PubSub, options?: { readonly shutdownOnEnd?: boolean | undefined; } | undefined): (self: Channel) => Effect.Effect; /** * @since 4.0.0 * @category Destructors */ (self: Channel, pubsub: PubSub.PubSub, options?: { readonly shutdownOnEnd?: boolean | undefined; } | undefined): Effect.Effect; }; /** * Converts a channel to a PubSub for concurrent consumption. * * `shutdownOnEnd` indicates whether the PubSub should be shut down when the * channel ends. By default this is `true`. * * @since 4.0.0 * @category Destructors */ export declare const toPubSubArray: { /** * Converts a channel to a PubSub for concurrent consumption. * * `shutdownOnEnd` indicates whether the PubSub should be shut down when the * channel ends. By default this is `true`. * * @since 4.0.0 * @category Destructors */ (options: { readonly capacity: "unbounded"; readonly replay?: number | undefined; readonly shutdownOnEnd?: boolean | undefined; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; readonly replay?: number | undefined; readonly shutdownOnEnd?: boolean | undefined; }): (self: Channel, OutErr, OutDone, unknown, unknown, unknown, Env>) => Effect.Effect, never, Env | Scope.Scope>; /** * Converts a channel to a PubSub for concurrent consumption. * * `shutdownOnEnd` indicates whether the PubSub should be shut down when the * channel ends. By default this is `true`. * * @since 4.0.0 * @category Destructors */ (self: Channel, OutErr, OutDone, unknown, unknown, unknown, Env>, options: { readonly capacity: "unbounded"; readonly replay?: number | undefined; readonly shutdownOnEnd?: boolean | undefined; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; readonly replay?: number | undefined; readonly shutdownOnEnd?: boolean | undefined; }): Effect.Effect, never, Env | Scope.Scope>; }; /** * @since 4.0.0 * @category Destructors */ export declare const runIntoPubSubArray: { /** * @since 4.0.0 * @category Destructors */ (pubsub: PubSub.PubSub, options?: { readonly shutdownOnEnd?: boolean | undefined; } | undefined): (self: Channel, OutErr, OutDone, unknown, unknown, unknown, Env>) => Effect.Effect; /** * @since 4.0.0 * @category Destructors */ (self: Channel, OutErr, OutDone, unknown, unknown, unknown, Env>, pubsub: PubSub.PubSub, options?: { readonly shutdownOnEnd?: boolean | undefined; } | undefined): Effect.Effect; }; /** * Converts a channel to a PubSub for concurrent consumption. * * @since 4.0.0 * @category Destructors */ export declare const toPubSubTake: { /** * Converts a channel to a PubSub for concurrent consumption. * * @since 4.0.0 * @category Destructors */ (options: { readonly capacity: "unbounded"; readonly replay?: number | undefined; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; readonly replay?: number | undefined; }): (self: Channel, OutErr, OutDone, unknown, unknown, unknown, Env>) => Effect.Effect>, never, Env | Scope.Scope>; /** * Converts a channel to a PubSub for concurrent consumption. * * @since 4.0.0 * @category Destructors */ (self: Channel, OutErr, OutDone, unknown, unknown, unknown, Env>, options: { readonly capacity: "unbounded"; readonly replay?: number | undefined; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined; readonly replay?: number | undefined; }): Effect.Effect>, never, Env | Scope.Scope>; }; //# sourceMappingURL=Channel.d.ts.map