/** * @since 2.0.0 */ import type * as Cause from "./Cause.js" import type * as ChildExecutorDecision from "./ChildExecutorDecision.js" import type * as Chunk from "./Chunk.js" import type * as Context from "./Context.js" import type * as Deferred from "./Deferred.js" import type * as Effect from "./Effect.js" import type * as Either from "./Either.js" import type * as Exit from "./Exit.js" import type { LazyArg } from "./Function.js" import * as channel from "./internal/channel.js" import * as core from "./internal/core-stream.js" import * as sink from "./internal/sink.js" import * as stream from "./internal/stream.js" import type * as Layer from "./Layer.js" import type * as MergeDecision from "./MergeDecision.js" import type * as MergeStrategy from "./MergeStrategy.js" import type * as Option from "./Option.js" import type { Pipeable } from "./Pipeable.js" import type { Predicate } from "./Predicate.js" import type * as PubSub from "./PubSub.js" import type * as Queue from "./Queue.js" import type * as Ref from "./Ref.js" import type * as Scope from "./Scope.js" import type * as SingleProducerAsyncInput from "./SingleProducerAsyncInput.js" import type * as Sink from "./Sink.js" import type * as Stream from "./Stream.js" import type * as Tracer from "./Tracer.js" import type * as Types from "./Types.js" import type * as Unify from "./Unify.js" import type * as UpstreamPullRequest from "./UpstreamPullRequest.js" import type * as UpstreamPullStrategy from "./UpstreamPullStrategy.js" /** * @since 2.0.0 * @category symbols */ export const ChannelTypeId: unique symbol = core.ChannelTypeId /** * @since 2.0.0 * @category symbols */ export type ChannelTypeId = typeof ChannelTypeId /** * 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. * * @since 2.0.0 * @category models */ // export interface Channel export interface Channel< out OutElem, in InElem = unknown, out OutErr = never, in InErr = unknown, out OutDone = void, in InDone = unknown, out Env = never > extends Channel.Variance< OutElem, InElem, OutErr, InErr, OutDone, InDone, Env >, 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 OutElem, infer InElem, infer OutErr, infer InErr, infer OutDone, infer InDone, infer Env > | infer _ ? Channel : never } /** * @category models * @since 2.0.0 */ export interface ChannelUnifyIgnore extends Effect.EffectUnifyIgnore { Channel?: true } /** * @since 2.0.0 * @category models */ declare module "./Effect.js" { interface Effect extends Channel {} interface EffectUnifyIgnore { Channel?: true } } /** * @since 2.0.0 */ export declare namespace Channel { /** * @since 2.0.0 * @category models */ export interface Variance { readonly [ChannelTypeId]: 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 } } /** * @since 2.0.0 * @category symbols */ export const ChannelExceptionTypeId: unique symbol = channel.ChannelExceptionTypeId /** * @since 2.0.0 * @category symbols */ export type ChannelExceptionTypeId = typeof ChannelExceptionTypeId /** * Represents a generic checked exception which occurs when a `Channel` is * executed. * * @since 2.0.0 * @category models */ export interface ChannelException { readonly _tag: "ChannelException" readonly [ChannelExceptionTypeId]: ChannelExceptionTypeId readonly error: E } /** * @since 3.5.4 * @category refinements */ export const isChannel: (u: unknown) => u is Channel< unknown, unknown, unknown, unknown, unknown, unknown, unknown > = core.isChannel /** * @since 2.0.0 * @category constructors */ export const acquireUseRelease: ( acquire: Effect.Effect, use: (a: Acquired) => Channel, release: (a: Acquired, exit: Exit.Exit) => Effect.Effect ) => Channel = channel.acquireUseRelease /** * @since 2.0.0 * @category constructors */ export const acquireReleaseOut: { /** * @since 2.0.0 * @category constructors */ ( release: (z: Z, e: Exit.Exit) => Effect.Effect ): (self: Effect.Effect) => Channel /** * @since 2.0.0 * @category constructors */ ( self: Effect.Effect, release: (z: Z, e: Exit.Exit) => Effect.Effect ): Channel } = core.acquireReleaseOut /** * Returns a new channel that is the same as this one, except the terminal * value of the channel is the specified constant value. * * This method produces the same result as mapping this channel to the * specified constant value. * * @since 2.0.0 * @category mapping */ export const as: { /** * Returns a new channel that is the same as this one, except the terminal * value of the channel is the specified constant value. * * This method produces the same result as mapping this channel to the * specified constant value. * * @since 2.0.0 * @category mapping */ (value: OutDone2): ( self: Channel ) => Channel /** * Returns a new channel that is the same as this one, except the terminal * value of the channel is the specified constant value. * * This method produces the same result as mapping this channel to the * specified constant value. * * @since 2.0.0 * @category mapping */ ( self: Channel, value: OutDone2 ): Channel } = channel.as /** * @since 2.0.0 * @category mapping */ export const asVoid: ( self: Channel ) => Channel = channel.asVoid /** * Creates a channel backed by a buffer. When the buffer is empty, the channel * will simply passthrough its input as output. However, when the buffer is * non-empty, the value inside the buffer will be passed along as output. * * @since 2.0.0 * @category constructors */ export const buffer: ( options: { readonly empty: InElem; readonly isEmpty: Predicate; readonly ref: Ref.Ref } ) => Channel = channel.buffer /** * @since 2.0.0 * @category constructors */ export const bufferChunk: ( ref: Ref.Ref> ) => Channel, Chunk.Chunk, InErr, InErr, InDone, InDone> = channel.bufferChunk /** * Returns a new channel that is the same as this one, except if this channel * errors for any typed error, then the returned channel will switch over to * using the fallback channel returned by the specified error handler. * * @since 2.0.0 * @category error handling */ export const catchAll: { /** * Returns a new channel that is the same as this one, except if this channel * errors for any typed error, then the returned channel will switch over to * using the fallback channel returned by the specified error handler. * * @since 2.0.0 * @category error handling */ ( f: (error: OutErr) => Channel ): ( self: Channel ) => Channel< OutElem1 | OutElem, InElem & InElem1, OutErr1, InErr & InErr1, OutDone1 | OutDone, InDone & InDone1, Env1 | Env > /** * Returns a new channel that is the same as this one, except if this channel * errors for any typed error, then the returned channel will switch over to * using the fallback channel returned by the specified error handler. * * @since 2.0.0 * @category error handling */ ( self: Channel, f: (error: OutErr) => Channel ): Channel< OutElem | OutElem1, InElem & InElem1, OutErr1, InErr & InErr1, OutDone | OutDone1, InDone & InDone1, Env | Env1 > } = channel.catchAll /** * Returns a new channel that is the same as this one, except if this channel * errors for any typed error, then the returned channel will switch over to * using the fallback channel returned by the specified error handler. * * @since 2.0.0 * @category error handling */ export const catchAllCause: { /** * Returns a new channel that is the same as this one, except if this channel * errors for any typed error, then the returned channel will switch over to * using the fallback channel returned by the specified error handler. * * @since 2.0.0 * @category error handling */ ( f: (cause: Cause.Cause) => Channel ): ( self: Channel ) => Channel< OutElem1 | OutElem, InElem & InElem1, OutErr1, InErr & InErr1, OutDone1 | OutDone, InDone & InDone1, Env1 | Env > /** * Returns a new channel that is the same as this one, except if this channel * errors for any typed error, then the returned channel will switch over to * using the fallback channel returned by the specified error handler. * * @since 2.0.0 * @category error handling */ ( self: Channel, f: (cause: Cause.Cause) => Channel ): Channel< OutElem | OutElem1, InElem & InElem1, OutErr1, InErr & InErr1, OutDone | OutDone1, InDone & InDone1, Env | Env1 > } = core.catchAllCause /** * Concat sequentially a channel of channels. * * @since 2.0.0 * @category constructors */ export const concatAll: ( channels: Channel, InElem, OutErr, InErr, any, InDone, Env> ) => Channel = core.concatAll /** * Concat sequentially a channel of channels. * * @since 2.0.0 * @category constructors */ export const concatAllWith: < OutElem, InElem2, OutErr2, InErr2, OutDone, InDone2, Env2, InElem, OutErr, InErr, OutDone2, InDone, Env, OutDone3 >( channels: Channel< Channel, InElem, OutErr, InErr, OutDone2, InDone, Env >, f: (o: OutDone, o1: OutDone) => OutDone, g: (o: OutDone, o2: OutDone2) => OutDone3 ) => Channel = core.concatAllWith /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. * * @since 2.0.0 * @category utils */ export const concatMap: { /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. * * @since 2.0.0 * @category utils */ ( f: (o: OutElem) => Channel ): ( self: Channel ) => Channel /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. * * @since 2.0.0 * @category utils */ ( self: Channel, f: (o: OutElem) => Channel ): Channel } = channel.concatMap /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. The provided merging function is used to * merge the terminal values of all channels into the single terminal value of * the returned channel. * * @since 2.0.0 * @category utils */ export const concatMapWith: { /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. The provided merging function is used to * merge the terminal values of all channels into the single terminal value of * the returned channel. * * @since 2.0.0 * @category utils */ ( f: (o: OutElem) => Channel, g: (o: OutDone, o1: OutDone) => OutDone, h: (o: OutDone, o2: OutDone2) => OutDone3 ): ( self: Channel ) => Channel /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. The provided merging function is used to * merge the terminal values of all channels into the single terminal value of * the returned channel. * * @since 2.0.0 * @category utils */ < OutElem, InElem, OutErr, InErr, OutDone2, InDone, Env, OutElem2, InElem2, OutErr2, InErr2, OutDone, InDone2, Env2, OutDone3 >( self: Channel, f: (o: OutElem) => Channel, g: (o: OutDone, o1: OutDone) => OutDone, h: (o: OutDone, o2: OutDone2) => OutDone3 ): Channel } = core.concatMapWith /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. The provided merging function is used to * merge the terminal values of all channels into the single terminal value of * the returned channel. * * @since 2.0.0 * @category utils */ export const concatMapWithCustom: { /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. The provided merging function is used to * merge the terminal values of all channels into the single terminal value of * the returned channel. * * @since 2.0.0 * @category utils */ ( f: (o: OutElem) => Channel, g: (o: OutDone, o1: OutDone) => OutDone, h: (o: OutDone, o2: OutDone2) => OutDone3, onPull: ( upstreamPullRequest: UpstreamPullRequest.UpstreamPullRequest ) => UpstreamPullStrategy.UpstreamPullStrategy, onEmit: (elem: OutElem2) => ChildExecutorDecision.ChildExecutorDecision ): ( self: Channel ) => Channel /** * Returns a new channel whose outputs are fed to the specified factory * function, which creates new channels in response. These new channels are * sequentially concatenated together, and all their outputs appear as outputs * of the newly returned channel. The provided merging function is used to * merge the terminal values of all channels into the single terminal value of * the returned channel. * * @since 2.0.0 * @category utils */ < OutElem, InElem, OutErr, InErr, OutDone2, InDone, Env, OutElem2, InElem2, OutErr2, InErr2, OutDone, InDone2, Env2, OutDone3 >( self: Channel, f: (o: OutElem) => Channel, g: (o: OutDone, o1: OutDone) => OutDone, h: (o: OutDone, o2: OutDone2) => OutDone3, onPull: ( upstreamPullRequest: UpstreamPullRequest.UpstreamPullRequest ) => UpstreamPullStrategy.UpstreamPullStrategy, onEmit: (elem: OutElem2) => ChildExecutorDecision.ChildExecutorDecision ): Channel } = core.concatMapWithCustom /** * Returns a new channel, which is the same as this one, except its outputs * are filtered and transformed by the specified partial function. * * @since 2.0.0 * @category utils */ export const collect: { /** * Returns a new channel, which is the same as this one, except its outputs * are filtered and transformed by the specified partial function. * * @since 2.0.0 * @category utils */ (pf: (o: OutElem) => Option.Option): ( self: Channel ) => Channel /** * Returns a new channel, which is the same as this one, except its outputs * are filtered and transformed by the specified partial function. * * @since 2.0.0 * @category utils */ ( self: Channel, pf: (o: OutElem) => Option.Option ): Channel } = channel.collect /** * Returns a new channel, which is the concatenation of all the channels that * are written out by this channel. This method may only be called on channels * that output other channels. * * @since 2.0.0 * @category utils */ export const concatOut: ( self: Channel< Channel, InElem, OutErr, InErr, OutDone, InDone, Env > ) => Channel = channel.concatOut /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's done value. * * @since 2.0.0 * @category utils */ export const mapInput: { /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's done value. * * @since 2.0.0 * @category utils */ (f: (a: InDone0) => InDone): ( self: Channel ) => Channel /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's done value. * * @since 2.0.0 * @category utils */ ( self: Channel, f: (a: InDone0) => InDone ): Channel } = channel.mapInput /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's done value. * * @since 2.0.0 * @category utils */ export const mapInputEffect: { /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's done value. * * @since 2.0.0 * @category utils */ (f: (i: InDone0) => Effect.Effect): ( self: Channel ) => Channel /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's done value. * * @since 2.0.0 * @category utils */ ( self: Channel, f: (i: InDone0) => Effect.Effect ): Channel } = channel.mapInputEffect /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's error value. * * @since 2.0.0 * @category utils */ export const mapInputError: { /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's error value. * * @since 2.0.0 * @category utils */ (f: (a: InErr0) => InErr): ( self: Channel ) => Channel /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's error value. * * @since 2.0.0 * @category utils */ ( self: Channel, f: (a: InErr0) => InErr ): Channel } = channel.mapInputError /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's error value. * * @since 2.0.0 * @category utils */ export const mapInputErrorEffect: { /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's error value. * * @since 2.0.0 * @category utils */ (f: (error: InErr0) => Effect.Effect): ( self: Channel ) => Channel /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's error value. * * @since 2.0.0 * @category utils */ ( self: Channel, f: (error: InErr0) => Effect.Effect ): Channel } = channel.mapInputErrorEffect /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's output elements. * * @since 2.0.0 * @category utils */ export const mapInputIn: { /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's output elements. * * @since 2.0.0 * @category utils */ (f: (a: InElem0) => InElem): ( self: Channel ) => Channel /** * Returns a new channel which is the same as this one but applies the given * function to the input channel's output elements. * * @since 2.0.0 * @category utils */ ( self: Channel, f: (a: InElem0) => InElem ): Channel } = channel.mapInputIn /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's output elements. * * @since 2.0.0 * @category utils */ export const mapInputInEffect: { /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's output elements. * * @since 2.0.0 * @category utils */ (f: (a: InElem0) => Effect.Effect): ( self: Channel ) => Channel /** * Returns a new channel which is the same as this one but applies the given * effectual function to the input channel's output elements. * * @since 2.0.0 * @category utils */ ( self: Channel, f: (a: InElem0) => Effect.Effect ): Channel } = channel.mapInputInEffect /** * Returns a new channel, which is the same as this one, except that all the * outputs are collected and bundled into a tuple together with the terminal * value of this channel. * * As the channel returned from this channel collects all of this channel's * output into an in- memory chunk, it is not safe to call this method on * channels that output a large or unbounded number of values. * * @since 2.0.0 * @category utils */ export const doneCollect: ( self: Channel ) => Channel, OutDone], InDone, Env> = channel.doneCollect /** * Returns a new channel which reads all the elements from upstream's output * channel and ignores them, then terminates with the upstream result value. * * @since 2.0.0 * @category utils */ export const drain: ( self: Channel ) => Channel = channel.drain /** * Returns a new channel which connects the given `AsyncInputProducer` as * this channel's input. * * @since 2.0.0 * @category utils */ export const embedInput: { /** * Returns a new channel which connects the given `AsyncInputProducer` as * this channel's input. * * @since 2.0.0 * @category utils */ (input: SingleProducerAsyncInput.AsyncInputProducer): ( self: Channel ) => Channel /** * Returns a new channel which connects the given `AsyncInputProducer` as * this channel's input. * * @since 2.0.0 * @category utils */ ( self: Channel, input: SingleProducerAsyncInput.AsyncInputProducer ): Channel } = core.embedInput /** * Returns a new channel that collects the output and terminal value of this * channel, which it then writes as output of the returned channel. * * @since 2.0.0 * @category utils */ export const emitCollect: ( self: Channel ) => Channel<[Chunk.Chunk, OutDone], InElem, OutErr, InErr, void, InDone, Env> = channel.emitCollect /** * 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). * * @since 2.0.0 * @category utils */ export 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). * * @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). * * @since 2.0.0 * @category utils */ ( self: Channel, finalizer: Effect.Effect ): Channel } = channel.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). * * @since 2.0.0 * @category utils */ export const ensuringWith: { /** * 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). * * @since 2.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). * * @since 2.0.0 * @category utils */ ( self: Channel, finalizer: (e: Exit.Exit) => Effect.Effect ): Channel } = core.ensuringWith /** * Accesses the whole context of the channel. * * @since 2.0.0 * @category context */ export const context: () => Channel, unknown, Env> = channel.context /** * Accesses the context of the channel with the specified function. * * @since 2.0.0 * @category context */ export const contextWith: ( f: (env: Context.Context) => OutDone ) => Channel = channel.contextWith /** * Accesses the context of the channel in the context of a channel. * * @since 2.0.0 * @category context */ export const contextWithChannel: ( f: (env: Context.Context) => Channel ) => Channel = channel.contextWithChannel /** * Accesses the context of the channel in the context of an effect. * * @since 2.0.0 * @category context */ export const contextWithEffect: ( f: (env: Context.Context) => Effect.Effect ) => Channel = channel.contextWithEffect /** * Constructs a channel that fails immediately with the specified error. * * @since 2.0.0 * @category constructors */ export const fail: (error: E) => Channel = core.fail /** * Constructs a channel that succeeds immediately with the specified lazily * evaluated value. * * @since 2.0.0 * @category constructors */ export const failSync: (evaluate: LazyArg) => Channel = core.failSync /** * Constructs a channel that fails immediately with the specified `Cause`. * * @since 2.0.0 * @category constructors */ export const failCause: (cause: Cause.Cause) => Channel = core.failCause /** * Constructs a channel that succeeds immediately with the specified lazily * evaluated `Cause`. * * @since 2.0.0 * @category constructors */ export const failCauseSync: ( evaluate: LazyArg> ) => Channel = core.failCauseSync /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the terminal value 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). * * @since 2.0.0 * @category sequencing */ export 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 terminal value 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). * * @since 2.0.0 * @category sequencing */ ( f: (d: OutDone) => Channel ): ( self: Channel ) => Channel< OutElem1 | OutElem, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, OutDone2, InDone & InDone1, Env1 | Env > /** * Returns a new channel, which sequentially combines this channel, together * with the provided factory function, which creates a second channel based on * the terminal value 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). * * @since 2.0.0 * @category sequencing */ ( self: Channel, f: (d: OutDone) => Channel ): Channel< OutElem | OutElem1, InElem & InElem1, OutErr | OutErr1, InErr & InErr1, OutDone2, InDone & InDone1, Env | Env1 > } = core.flatMap /** * Returns a new channel, which flattens the terminal value of this channel. * This function may only be called if the terminal value of this channel is * another channel of compatible types. * * @since 2.0.0 * @category sequencing */ export const flatten: < OutElem, InElem, OutErr, InErr, OutElem1, InElem1, OutErr1, InErr1, OutDone2, InDone1, Env1, InDone, Env >( self: Channel< OutElem, InElem, OutErr, InErr, Channel, InDone, Env > ) => Channel< OutElem | OutElem1, InElem & InElem1, OutErr | OutErr1, InErr & InErr1, OutDone2, InDone & InDone1, Env1 | Env > = channel.flatten /** * Folds over the result of this channel. * * @since 2.0.0 * @category utils */ export const foldChannel: { /** * Folds over the result of this channel. * * @since 2.0.0 * @category utils */ < OutErr, OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1, OutDone, OutElem2, InElem2, OutErr2, InErr2, OutDone2, InDone2, Env2 >( options: { readonly onFailure: (error: OutErr) => Channel readonly onSuccess: (done: OutDone) => Channel } ): ( self: Channel ) => Channel< OutElem1 | OutElem2 | OutElem, InElem & InElem1 & InElem2, OutErr1 | OutErr2, InErr & InErr1 & InErr2, OutDone1 | OutDone2, InDone & InDone1 & InDone2, Env1 | Env2 | Env > /** * Folds over the result of this channel. * * @since 2.0.0 * @category utils */ < OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1, OutElem2, InElem2, OutErr2, InErr2, OutDone2, InDone2, Env2 >( self: Channel, options: { readonly onFailure: (error: OutErr) => Channel readonly onSuccess: (done: OutDone) => Channel } ): Channel< OutElem | OutElem1 | OutElem2, InElem & InElem1 & InElem2, OutErr1 | OutErr2, InErr & InErr1 & InErr2, OutDone1 | OutDone2, InDone & InDone1 & InDone2, Env | Env1 | Env2 > } = channel.foldChannel /** * Folds over the result of this channel including any cause of termination. * * @since 2.0.0 * @category utils */ export const foldCauseChannel: { /** * Folds over the result of this channel including any cause of termination. * * @since 2.0.0 * @category utils */ < OutErr, OutElem1, InElem1, OutErr2, InErr1, OutDone2, InDone1, Env1, OutDone, OutElem2, InElem2, OutErr3, InErr2, OutDone3, InDone2, Env2 >( options: { readonly onFailure: ( c: Cause.Cause ) => Channel readonly onSuccess: (o: OutDone) => Channel } ): ( self: Channel ) => Channel< OutElem1 | OutElem2 | OutElem, InElem & InElem1 & InElem2, OutErr2 | OutErr3, InErr & InErr1 & InErr2, OutDone2 | OutDone3, InDone & InDone1 & InDone2, Env1 | Env2 | Env > /** * Folds over the result of this channel including any cause of termination. * * @since 2.0.0 * @category utils */ < OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, InElem1, OutErr2, InErr1, OutDone2, InDone1, Env1, OutElem2, InElem2, OutErr3, InErr2, OutDone3, InDone2, Env2 >( self: Channel, options: { readonly onFailure: ( c: Cause.Cause ) => Channel readonly onSuccess: (o: OutDone) => Channel } ): Channel< OutElem | OutElem1 | OutElem2, InElem & InElem1 & InElem2, OutErr2 | OutErr3, InErr & InErr1 & InErr2, OutDone2 | OutDone3, InDone & InDone1 & InDone2, Env | Env1 | Env2 > } = core.foldCauseChannel /** * Use an effect to end a channel. * * @since 2.0.0 * @category constructors */ export const fromEffect: ( effect: Effect.Effect ) => Channel = core.fromEffect /** * Constructs a channel from an `Either`. * * @since 2.0.0 * @category constructors */ export const fromEither: (either: Either.Either) => Channel = channel.fromEither /** * Construct a `Channel` from an `AsyncInputConsumer`. * * @since 2.0.0 * @category constructors */ export const fromInput: ( input: SingleProducerAsyncInput.AsyncInputConsumer ) => Channel = channel.fromInput /** * Construct a `Channel` from a `PubSub`. * * @since 2.0.0 * @category constructors */ export const fromPubSub: ( pubsub: PubSub.PubSub>> ) => Channel = channel.fromPubSub /** * Construct a `Channel` from a `PubSub` within a scoped effect. * * @since 2.0.0 * @category constructors */ export const fromPubSubScoped: ( pubsub: PubSub.PubSub>> ) => Effect.Effect, never, Scope.Scope> = channel.fromPubSubScoped /** * Construct a `Channel` from an `Option`. * * @since 2.0.0 * @category constructors */ export const fromOption: ( option: Option.Option ) => Channel, unknown, A, unknown> = channel.fromOption /** * Construct a `Channel` from a `Queue`. * * @since 2.0.0 * @category constructors */ export const fromQueue: ( queue: Queue.Dequeue>> ) => Channel = channel.fromQueue /** * @since 2.0.0 * @category constructors */ export const identity: () => Channel = channel.identityChannel /** * 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 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 } = channel.interruptWhen /** * Returns a new channel, which is the same as this one, except it will be * interrupted when the specified deferred is completed. If the deferred is * completed before the underlying channel is done, then the returned channel * will yield the value of the deferred. Otherwise, if the underlying channel * finishes first, then the returned channel will yield the value of the * underlying channel. * * @since 2.0.0 * @category utils */ export const interruptWhenDeferred: { /** * Returns a new channel, which is the same as this one, except it will be * interrupted when the specified deferred is completed. If the deferred is * completed before the underlying channel is done, then the returned channel * will yield the value of the deferred. Otherwise, if the underlying channel * finishes first, then the returned channel will yield the value of the * underlying channel. * * @since 2.0.0 * @category utils */ (deferred: Deferred.Deferred): ( self: Channel ) => Channel /** * Returns a new channel, which is the same as this one, except it will be * interrupted when the specified deferred is completed. If the deferred is * completed before the underlying channel is done, then the returned channel * will yield the value of the deferred. Otherwise, if the underlying channel * finishes first, then the returned channel will yield the value of the * underlying channel. * * @since 2.0.0 * @category utils */ ( self: Channel, deferred: Deferred.Deferred ): Channel } = channel.interruptWhenDeferred /** * Returns a new channel, which is the same as this one, except the terminal * value of the returned channel is created by applying the specified function * to the terminal value of this channel. * * @since 2.0.0 * @category mapping */ export const map: { /** * Returns a new channel, which is the same as this one, except the terminal * value of the returned channel is created by applying the specified function * to the terminal value of this channel. * * @since 2.0.0 * @category mapping */ (f: (out: OutDone) => OutDone2): ( self: Channel ) => Channel /** * Returns a new channel, which is the same as this one, except the terminal * value of the returned channel is created by applying the specified function * to the terminal value of this channel. * * @since 2.0.0 * @category mapping */ ( self: Channel, f: (out: OutDone) => OutDone2 ): Channel } = channel.map /** * Returns a new channel, which is the same as this one, except the terminal * value of the returned channel is created by applying the specified * effectful function to the terminal value of this channel. * * @since 2.0.0 * @category mapping */ export const mapEffect: { /** * Returns a new channel, which is the same as this one, except the terminal * value of the returned channel is created by applying the specified * effectful function to the terminal value of this channel. * * @since 2.0.0 * @category mapping */ (f: (o: OutDone) => Effect.Effect): ( self: Channel ) => Channel /** * Returns a new channel, which is the same as this one, except the terminal * value of the returned channel is created by applying the specified * effectful function to the terminal value of this channel. * * @since 2.0.0 * @category mapping */ ( self: Channel, f: (o: OutDone) => Effect.Effect ): Channel } = channel.mapEffect /** * 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 mapping */ export 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 mapping */ (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 mapping */ ( self: Channel, f: (err: OutErr) => OutErr2 ): Channel } = channel.mapError /** * A more powerful version of `mapError` which also surfaces the `Cause` * of the channel failure. * * @since 2.0.0 * @category mapping */ export const mapErrorCause: { /** * A more powerful version of `mapError` which also surfaces the `Cause` * of the channel failure. * * @since 2.0.0 * @category mapping */ (f: (cause: Cause.Cause) => Cause.Cause): ( self: Channel ) => Channel /** * A more powerful version of `mapError` which also surfaces the `Cause` * of the channel failure. * * @since 2.0.0 * @category mapping */ ( self: Channel, f: (cause: Cause.Cause) => Cause.Cause ): Channel } = channel.mapErrorCause /** * Maps the output of this channel using the specified function. * * @since 2.0.0 * @category mapping */ export const mapOut: { /** * Maps the output of this channel using the specified function. * * @since 2.0.0 * @category mapping */ (f: (o: OutElem) => OutElem2): ( self: Channel ) => Channel /** * Maps the output of this channel using the specified function. * * @since 2.0.0 * @category mapping */ ( self: Channel, f: (o: OutElem) => OutElem2 ): Channel } = channel.mapOut /** * Creates a channel that is like this channel but the given effectful function * gets applied to each emitted output element. * * @since 2.0.0 * @category mapping */ export const mapOutEffect: { /** * Creates a channel that is like this channel but the given effectful function * gets applied to each emitted output element. * * @since 2.0.0 * @category mapping */ (f: (o: OutElem) => Effect.Effect): ( self: Channel ) => Channel /** * Creates a channel that is like this channel but the given effectful function * gets applied to each emitted output element. * * @since 2.0.0 * @category mapping */ ( self: Channel, f: (o: OutElem) => Effect.Effect ): Channel } = channel.mapOutEffect /** * Creates a channel that is like this channel but the given ZIO function gets * applied to each emitted output element, taking `n` elements at once and * mapping them in parallel. * * @since 2.0.0 * @category mapping */ export const mapOutEffectPar: { /** * Creates a channel that is like this channel but the given ZIO function gets * applied to each emitted output element, taking `n` elements at once and * mapping them in parallel. * * @since 2.0.0 * @category mapping */ (f: (o: OutElem) => Effect.Effect, n: number): ( self: Channel ) => Channel /** * Creates a channel that is like this channel but the given ZIO function gets * applied to each emitted output element, taking `n` elements at once and * mapping them in parallel. * * @since 2.0.0 * @category mapping */ ( self: Channel, f: (o: OutElem) => Effect.Effect, n: number ): Channel } = channel.mapOutEffectPar /** * @since 2.0.0 * @category utils */ export const mergeAll: ( options: { readonly concurrency: number | "unbounded" readonly bufferSize?: number | undefined readonly mergeStrategy?: MergeStrategy.MergeStrategy | undefined } ) => ( channels: Channel< Channel, InElem, OutErr, InErr, unknown, InDone, Env > ) => Channel = channel.mergeAll /** * @since 2.0.0 * @category utils */ export const mergeAllUnbounded: ( channels: Channel< Channel, InElem, OutErr, InErr, unknown, InDone, Env > ) => Channel = channel.mergeAllUnbounded /** * @since 2.0.0 * @category utils */ export const mergeAllUnboundedWith: < OutElem, InElem1, OutErr1, InErr1, OutDone, InDone1, Env1, InElem, OutErr, InErr, InDone, Env >( channels: Channel< Channel, InElem, OutErr, InErr, OutDone, InDone, Env >, f: (o1: OutDone, o2: OutDone) => OutDone ) => Channel = channel.mergeAllUnboundedWith /** * @since 2.0.0 * @category utils */ export const mergeAllWith: ( { bufferSize, concurrency, mergeStrategy }: { readonly concurrency: number | "unbounded" readonly bufferSize?: number | undefined readonly mergeStrategy?: MergeStrategy.MergeStrategy | undefined } ) => ( channels: Channel< Channel, InElem, OutErr, InErr, OutDone, InDone, Env >, f: (o1: OutDone, o2: OutDone) => OutDone ) => Channel = channel.mergeAllWith /** * Returns a new channel which creates a new channel for each emitted element * and merges some of them together. Different merge strategies control what * happens if there are more than the given maximum number of channels gets * created. See `Channel.mergeAll`. * * @since 2.0.0 * @category mapping */ export const mergeMap: { /** * Returns a new channel which creates a new channel for each emitted element * and merges some of them together. Different merge strategies control what * happens if there are more than the given maximum number of channels gets * created. See `Channel.mergeAll`. * * @since 2.0.0 * @category mapping */ ( f: (outElem: OutElem) => Channel, options: { readonly concurrency: number | "unbounded" readonly bufferSize?: number | undefined readonly mergeStrategy?: MergeStrategy.MergeStrategy | undefined } ): ( self: Channel ) => Channel /** * Returns a new channel which creates a new channel for each emitted element * and merges some of them together. Different merge strategies control what * happens if there are more than the given maximum number of channels gets * created. See `Channel.mergeAll`. * * @since 2.0.0 * @category mapping */ ( self: Channel, f: (outElem: OutElem) => Channel, options: { readonly concurrency: number | "unbounded" readonly bufferSize?: number | undefined readonly mergeStrategy?: MergeStrategy.MergeStrategy | undefined } ): Channel } = channel.mergeMap /** * Returns a new channel which merges a number of channels emitted by this * channel using the back pressuring merge strategy. See `Channel.mergeAll`. * * @since 2.0.0 * @category utils */ export const mergeOut: { /** * Returns a new channel which merges a number of channels emitted by this * channel using the back pressuring merge strategy. See `Channel.mergeAll`. * * @since 2.0.0 * @category utils */ (n: number): ( self: Channel< Channel, InElem, OutErr, InErr, OutDone, InDone, Env > ) => Channel /** * Returns a new channel which merges a number of channels emitted by this * channel using the back pressuring merge strategy. See `Channel.mergeAll`. * * @since 2.0.0 * @category utils */ ( self: Channel< Channel, InElem, OutErr, InErr, OutDone, InDone, Env >, n: number ): Channel } = channel.mergeOut /** * Returns a new channel which merges a number of channels emitted by this * channel using the back pressuring merge strategy and uses a given function * to merge each completed subchannel's result value. See * `Channel.mergeAll`. * * @since 2.0.0 * @category utils */ export const mergeOutWith: { /** * Returns a new channel which merges a number of channels emitted by this * channel using the back pressuring merge strategy and uses a given function * to merge each completed subchannel's result value. See * `Channel.mergeAll`. * * @since 2.0.0 * @category utils */ (n: number, f: (o1: OutDone1, o2: OutDone1) => OutDone1): ( self: Channel< Channel, InElem, OutErr, InErr, OutDone1, InDone, Env > ) => Channel /** * Returns a new channel which merges a number of channels emitted by this * channel using the back pressuring merge strategy and uses a given function * to merge each completed subchannel's result value. See * `Channel.mergeAll`. * * @since 2.0.0 * @category utils */ ( self: Channel< Channel, InElem, OutErr, InErr, OutDone1, InDone, Env >, n: number, f: (o1: OutDone1, o2: OutDone1) => OutDone1 ): Channel } = channel.mergeOutWith /** * Returns a new channel, which is the merge of this channel and the specified * channel, where the behavior of the returned channel on left or right early * termination is decided by the specified `leftDone` and `rightDone` merge * decisions. * * @since 2.0.0 * @category utils */ export const mergeWith: { /** * Returns a new channel, which is the merge of this channel and the specified * channel, where the behavior of the returned channel on left or right early * termination is decided by the specified `leftDone` and `rightDone` merge * decisions. * * @since 2.0.0 * @category utils */ ( options: { readonly other: Channel readonly onSelfDone: ( exit: Exit.Exit ) => MergeDecision.MergeDecision readonly onOtherDone: ( ex: Exit.Exit ) => MergeDecision.MergeDecision } ): ( self: Channel ) => Channel< OutElem1 | OutElem, InElem & InElem1, OutErr2 | OutErr3, InErr & InErr1, OutDone2 | OutDone3, InDone & InDone1, Env1 | Env > /** * Returns a new channel, which is the merge of this channel and the specified * channel, where the behavior of the returned channel on left or right early * termination is decided by the specified `leftDone` and `rightDone` merge * decisions. * * @since 2.0.0 * @category utils */ < OutElem, InElem, OutErr, InErr, OutDone, InDone, Env, OutElem1, InElem1, OutErr1, InErr1, OutDone1, InDone1, Env1, OutErr2, OutDone2, OutErr3, OutDone3 >( self: Channel, options: { readonly other: Channel readonly onSelfDone: ( exit: Exit.Exit ) => MergeDecision.MergeDecision readonly onOtherDone: ( ex: Exit.Exit ) => MergeDecision.MergeDecision } ): Channel< OutElem | OutElem1, InElem & InElem1, OutErr2 | OutErr3, InErr & InErr1, OutDone2 | OutDone3, InDone & InDone1, Env | Env1 > } = channel.mergeWith /** * Returns a channel that never completes * * @since 2.0.0 * @category constructors */ export const never: Channel = channel.never /** * Translates channel failure into death of the fiber, making all failures * unchecked and not a part of the type of the channel. * * @since 2.0.0 * @category error handling */ export const orDie: { /** * Translates channel failure into death of the fiber, making all failures * unchecked and not a part of the type of the channel. * * @since 2.0.0 * @category error handling */ (error: LazyArg): ( self: Channel ) => Channel /** * Translates channel failure into death of the fiber, making all failures * unchecked and not a part of the type of the channel. * * @since 2.0.0 * @category error handling */ ( self: Channel, error: LazyArg ): Channel } = channel.orDie /** * Keeps none of the errors, and terminates the fiber with them, using the * specified function to convert the `OutErr` into a defect. * * @since 2.0.0 * @category error handling */ export const orDieWith: { /** * Keeps none of the errors, and terminates the fiber with them, using the * specified function to convert the `OutErr` into a defect. * * @since 2.0.0 * @category error handling */ (f: (e: OutErr) => unknown): ( self: Channel ) => Channel /** * Keeps none of the errors, and terminates the fiber with them, using the * specified function to convert the `OutErr` into a defect. * * @since 2.0.0 * @category error handling */ ( self: Channel, f: (e: OutErr) => unknown ): Channel } = channel.orDieWith /** * Returns a new channel that will perform the operations of this one, until * failure, and then it will switch over to the operations of the specified * fallback channel. * * @since 2.0.0 * @category error handling */ export const orElse: { /** * Returns a new channel that will perform the operations of this one, until * failure, and then it will switch over to the operations of the specified * fallback channel. * * @since 2.0.0 * @category error handling */ ( that: LazyArg> ): ( self: Channel ) => Channel< OutElem1 | OutElem, InElem & InElem1, OutErr1, InErr & InErr1, OutDone1 | OutDone, InDone & InDone1, Env1 | Env > /** * Returns a new channel that will perform the operations of this one, until * failure, and then it will switch over to the operations of the specified * fallback channel. * * @since 2.0.0 * @category error handling */ ( self: Channel, that: LazyArg> ): Channel< OutElem | OutElem1, InElem & InElem1, OutErr1, InErr & InErr1, OutDone | OutDone1, InDone & InDone1, Env | Env1 > } = channel.orElse /** * 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. * * @since 2.0.0 * @category utils */ export 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. * * @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. * * @since 2.0.0 * @category utils */ ( self: Channel, that: Channel ): Channel } = core.pipeTo /** * 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. * * @since 2.0.0 * @category utils */ export 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. * * @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. * * @since 2.0.0 * @category utils */ ( self: Channel, that: Channel ): Channel } = channel.pipeToOrFail /** * Provides the channel with its required context, which eliminates its * dependency on `Env`. * * @since 2.0.0 * @category context */ export const provideContext: { /** * Provides the channel with its required context, which eliminates its * dependency on `Env`. * * @since 2.0.0 * @category context */ (env: Context.Context): ( self: Channel ) => Channel /** * Provides the channel with its required context, which eliminates its * dependency on `Env`. * * @since 2.0.0 * @category context */ ( self: Channel, env: Context.Context ): Channel } = core.provideContext /** * Provides a layer to the channel, which translates it to another level. * * @since 2.0.0 * @category context */ export const provideLayer: { /** * Provides a layer to the channel, which translates it to another level. * * @since 2.0.0 * @category context */ (layer: Layer.Layer): ( self: Channel ) => Channel /** * Provides a layer to the channel, which translates it to another level. * * @since 2.0.0 * @category context */ ( self: Channel, layer: Layer.Layer ): Channel } = channel.provideLayer /** * Transforms the context being provided to the channel with the specified * function. * * @since 2.0.0 * @category context */ export const mapInputContext: { /** * Transforms the context being provided to the channel with the specified * function. * * @since 2.0.0 * @category context */ (f: (env: Context.Context) => Context.Context): ( self: Channel ) => Channel /** * Transforms the context being provided to the channel with the specified * function. * * @since 2.0.0 * @category context */ ( self: Channel, f: (env: Context.Context) => Context.Context ): Channel } = channel.mapInputContext /** * Splits the context into two parts, providing one part using the * specified layer and leaving the remainder `Env0`. * * @since 2.0.0 * @category context */ export const provideSomeLayer: { /** * Splits the context into two parts, providing one part using the * specified layer and leaving the remainder `Env0`. * * @since 2.0.0 * @category context */ (layer: Layer.Layer): ( self: Channel ) => Channel> /** * Splits the context into two parts, providing one part using the * specified layer and leaving the remainder `Env0`. * * @since 2.0.0 * @category context */ ( self: Channel, layer: Layer.Layer ): Channel> } = channel.provideSomeLayer /** * Provides the effect with the single service it requires. If the effect * requires more than one service use `provideContext` instead. * * @since 2.0.0 * @category context */ export const provideService: { /** * Provides the effect with the single service it requires. If the effect * requires more than one service use `provideContext` instead. * * @since 2.0.0 * @category context */ (tag: Context.Tag, service: Types.NoInfer): ( self: Channel ) => Channel> /** * Provides the effect with the single service it requires. If the effect * requires more than one service use `provideContext` instead. * * @since 2.0.0 * @category context */ ( self: Channel, tag: Context.Tag, service: Types.NoInfer ): Channel> } = channel.provideService /** * @since 2.0.0 * @category constructors */ export const read: () => Channel, unknown, In, unknown> = channel.read /** * @since 2.0.0 * @category constructors */ export const readOrFail: (error: E) => Channel = core.readOrFail /** * @since 2.0.0 * @category constructors */ export const readWith: < InElem, OutElem, OutErr, InErr, OutDone, InDone, Env, OutElem2, OutErr2, OutDone2, Env2, OutElem3, OutErr3, OutDone3, Env3 >( options: { readonly onInput: (input: InElem) => Channel readonly onFailure: (error: InErr) => Channel readonly onDone: (done: InDone) => Channel } ) => Channel< OutElem | OutElem2 | OutElem3, InElem, OutErr | OutErr2 | OutErr3, InErr, OutDone | OutDone2 | OutDone3, InDone, Env | Env2 | Env3 > = core.readWith /** * @since 2.0.0 * @category constructors */ export const readWithCause: < InElem, OutElem, OutErr, InErr, OutDone, InDone, Env, OutElem2, OutErr2, OutDone2, Env2, OutElem3, OutErr3, OutDone3, Env3 >( options: { readonly onInput: (input: InElem) => Channel readonly onFailure: (cause: Cause.Cause) => Channel readonly onDone: (done: InDone) => Channel } ) => Channel< OutElem | OutElem2 | OutElem3, InElem, OutErr | OutErr2 | OutErr3, InErr, OutDone | OutDone2 | OutDone3, InDone, Env | Env2 | Env3 > = core.readWithCause /** * Creates a channel which repeatedly runs this channel. * * @since 2.0.0 * @category utils */ export const repeated: ( self: Channel ) => Channel = channel.repeated /** * Runs a channel until the end is received. * * @since 2.0.0 * @category destructors */ export const run: ( self: Channel ) => Effect.Effect = channel.run /** * Run the channel until it finishes with a done value or fails with an error * and collects its emitted output elements. * * The channel must not read any input. * * @since 2.0.0 * @category destructors */ export const runCollect: ( self: Channel ) => Effect.Effect<[Chunk.Chunk, OutDone], OutErr, Env> = channel.runCollect /** * Runs a channel until the end is received. * * @since 2.0.0 * @category destructors */ export const runDrain: ( self: Channel ) => Effect.Effect = channel.runDrain /** * Run the channel until it finishes with a done value or fails with an error. * The channel must not read any input or write any output. * * Closing the channel, which includes execution of all the finalizers * attached to the channel will be added to the current scope as a finalizer. * * @since 3.11.0 * @category destructors */ export const runScoped: ( self: Channel ) => Effect.Effect = channel.runScoped /** * Use a scoped effect to emit an output element. * * @since 2.0.0 * @category constructors */ export const scoped: ( effect: Effect.Effect ) => Channel> = channel.scoped /** * Use a function that receives a scope and returns an effect to emit an output * element. The output element will be the result of the returned effect, if * successful. * * @since 3.11.0 * @category constructors */ export const scopedWith: ( f: (scope: Scope.Scope) => Effect.Effect ) => Channel = channel.scopedWith /** * Splits strings on newlines. Handles both Windows newlines (`\r\n`) and UNIX * newlines (`\n`). * * @since 2.0.0 * @category combinators */ export const splitLines: () => Channel< Chunk.Chunk, Chunk.Chunk, Err, Err, Done, Done, never > = channel.splitLines /** * Constructs a channel that succeeds immediately with the specified value. * * @since 2.0.0 * @category constructors */ export const succeed: (value: A) => Channel = core.succeed /** * Lazily constructs a channel from the given side effect. * * @since 2.0.0 * @category constructors */ export const suspend: ( evaluate: LazyArg> ) => Channel = core.suspend /** * Constructs a channel that succeeds immediately with the specified lazy value. * * @since 2.0.0 * @category constructors */ export const sync: ( evaluate: LazyArg ) => Channel = core.sync /** * Converts a `Channel` to a `PubSub`. * * @since 2.0.0 * @category destructors */ export const toPubSub: ( pubsub: PubSub.PubSub>> ) => Channel = channel.toPubSub /** * Returns a scoped `Effect` that can be used to repeatedly pull elements from * the constructed `Channel`. The pull effect fails with the channel's failure * in case the channel fails, or returns either the channel's done value or an * emitted element. * * @since 2.0.0 * @category destructors */ export const toPull: ( self: Channel ) => Effect.Effect, OutErr, Env>, never, Scope.Scope | Env> = channel.toPull /** * Returns an `Effect` that can be used to repeatedly pull elements from the * constructed `Channel` within the provided `Scope`. The pull effect fails * with the channel's failure in case the channel fails, or returns either the * channel's done value or an emitted element. * * @since 3.11.0 * @category destructors */ export const toPullIn: { /** * Returns an `Effect` that can be used to repeatedly pull elements from the * constructed `Channel` within the provided `Scope`. The pull effect fails * with the channel's failure in case the channel fails, or returns either the * channel's done value or an emitted element. * * @since 3.11.0 * @category destructors */ (scope: Scope.Scope): ( self: Channel ) => Effect.Effect, OutErr, Env>, never, Env> /** * Returns an `Effect` that can be used to repeatedly pull elements from the * constructed `Channel` within the provided `Scope`. The pull effect fails * with the channel's failure in case the channel fails, or returns either the * channel's done value or an emitted element. * * @since 3.11.0 * @category destructors */ ( self: Channel, scope: Scope.Scope ): Effect.Effect, OutErr, Env>, never, Env> } = channel.toPullIn /** * Converts a `Channel` to a `Queue`. * * @since 2.0.0 * @category destructors */ export const toQueue: ( queue: Queue.Enqueue>> ) => Channel = channel.toQueue /** Converts this channel to a `Sink`. * * @since 2.0.0 * @category destructors */ export const toSink: ( self: Channel, Chunk.Chunk, OutErr, InErr, OutDone, unknown, Env> ) => Sink.Sink = sink.channelToSink /** * Converts this channel to a `Stream`. * * @since 2.0.0 * @category destructors */ export const toStream: ( self: Channel, unknown, OutErr, unknown, OutDone, unknown, Env> ) => Stream.Stream = stream.channelToStream const void_: Channel = core.void export { /** * @since 2.0.0 * @category constructors */ void_ as void } /** * Constructs a `Channel` from an effect that will result in a `Channel` if * successful. * * @since 2.0.0 * @category constructors */ export const unwrap: ( channel: Effect.Effect, E, R> ) => Channel = channel.unwrap /** * Constructs a `Channel` from a scoped effect that will result in a * `Channel` if successful. * * @since 2.0.0 * @category constructors */ export const unwrapScoped: ( self: Effect.Effect, E, R> ) => Channel> = channel.unwrapScoped /** * Constructs a `Channel` from a function which receives a `Scope` and returns * an effect that will result in a `Channel` if successful. * * @since 3.11.0 * @category constructors */ export const unwrapScopedWith: ( f: (scope: Scope.Scope) => Effect.Effect, E, R> ) => Channel = channel.unwrapScopedWith /** * Updates a service in the context of this channel. * * @since 2.0.0 * @category context */ export const updateService: { /** * Updates a service in the context of this channel. * * @since 2.0.0 * @category context */ ( tag: Context.Tag, f: (resource: Types.NoInfer) => Types.NoInfer ): ( self: Channel ) => Channel /** * Updates a service in the context of this channel. * * @since 2.0.0 * @category context */ ( self: Channel, tag: Context.Tag, f: (resource: Types.NoInfer) => Types.NoInfer ): Channel } = channel.updateService /** * Wraps the channel with a new span for tracing. * * @since 2.0.0 * @category tracing */ export const withSpan: { /** * Wraps the channel with a new span for tracing. * * @since 2.0.0 * @category tracing */ (name: string, options?: Tracer.SpanOptions | undefined): ( self: Channel ) => Channel> /** * Wraps the channel with a new span for tracing. * * @since 2.0.0 * @category tracing */ ( self: Channel, name: string, options?: Tracer.SpanOptions | undefined ): Channel> } = channel.withSpan /** * Writes a single value to the channel. * * @since 2.0.0 * @category constructors */ export const write: (out: OutElem) => Channel = core.write /** * Writes a sequence of values to the channel. * * @since 2.0.0 * @category constructors */ export const writeAll: >( ...outs: OutElems ) => Channel = channel.writeAll /** * Writes a `Chunk` of values to the channel. * * @since 2.0.0 * @category constructors */ export const writeChunk: ( outs: Chunk.Chunk ) => Channel = channel.writeChunk /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with a tuple of * the terminal values of both channels. * * @since 2.0.0 * @category zipping */ export const zip: { /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with a tuple of * the terminal values of both channels. * * @since 2.0.0 * @category zipping */ ( that: Channel, options?: { readonly concurrent?: boolean | undefined } | undefined ): ( self: Channel ) => Channel< OutElem1 | OutElem, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, readonly [OutDone, OutDone1], InDone & InDone1, Env1 | Env > /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with a tuple of * the terminal values of both channels. * * @since 2.0.0 * @category zipping */ ( self: Channel, that: Channel, options?: { readonly concurrent?: boolean | undefined } | undefined ): Channel< OutElem | OutElem1, InElem & InElem1, OutErr | OutErr1, InErr & InErr1, readonly [OutDone, OutDone1], InDone & InDone1, Env | Env1 > } = channel.zip /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with the * terminal value of this channel. * * @since 2.0.0 * @category zipping */ export const zipLeft: { /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with the * terminal value of this channel. * * @since 2.0.0 * @category zipping */ ( that: Channel, options?: { readonly concurrent?: boolean | undefined } | undefined ): ( self: Channel ) => Channel< OutElem1 | OutElem, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, OutDone, InDone & InDone1, Env1 | Env > /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with the * terminal value of this channel. * * @since 2.0.0 * @category zipping */ ( self: Channel, that: Channel, options?: { readonly concurrent?: boolean | undefined } | undefined ): Channel< OutElem | OutElem1, InElem & InElem1, OutErr | OutErr1, InErr & InErr1, OutDone, InDone & InDone1, Env | Env1 > } = channel.zipLeft /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with the * terminal value of that channel. * * @since 2.0.0 * @category zipping */ export const zipRight: { /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with the * terminal value of that channel. * * @since 2.0.0 * @category zipping */ ( that: Channel, options?: { readonly concurrent?: boolean | undefined } ): ( self: Channel ) => Channel< OutElem1 | OutElem, InElem & InElem1, OutErr1 | OutErr, InErr & InErr1, OutDone1, InDone & InDone1, Env1 | Env > /** * Returns a new channel that is the sequential composition of this channel * and the specified channel. The returned channel terminates with the * terminal value of that channel. * * @since 2.0.0 * @category zipping */ ( self: Channel, that: Channel, options?: { readonly concurrent?: boolean | undefined } ): Channel< OutElem | OutElem1, InElem & InElem1, OutErr | OutErr1, InErr & InErr1, OutDone1, InDone & InDone1, Env | Env1 > } = channel.zipRight /** * Represents a generic checked exception which occurs when a `Channel` is * executed. * * @since 2.0.0 * @category errors */ export const ChannelException: (error: E) => ChannelException = channel.ChannelException /** * Returns `true` if the specified value is an `ChannelException`, `false` * otherwise. * * @since 2.0.0 * @category refinements */ export const isChannelException: (u: unknown) => u is ChannelException = channel.isChannelException