UNPKG

veffect

Version:

powerful TypeScript validation library built on the robust foundation of Effect combining exceptional type safety, high performance, and developer experience. Taking inspiration from Effect's functional principles, VEffect delivers a balanced approach tha

1,555 lines (1,448 loc) 146 kB
/** * @since 2.0.0 */ import type * as Cause from "./Cause.js" import type * as Channel from "./Channel.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 Duration from "./Duration.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 type * as GroupBy from "./GroupBy.js" import type { TypeLambda } from "./HKT.js" import * as _groupBy from "./internal/groupBy.js" import * as internal from "./internal/stream.js" import type * as Layer from "./Layer.js" import type * as Option from "./Option.js" import type * as Order from "./Order.js" import type { Pipeable } from "./Pipeable.js" import type { Predicate, Refinement } from "./Predicate.js" import type * as PubSub from "./PubSub.js" import type * as Queue from "./Queue.js" import type * as Schedule from "./Schedule.js" import type * as Scope from "./Scope.js" import type * as Sink from "./Sink.js" import type * as Emit from "./StreamEmit.js" import type * as HaltStrategy from "./StreamHaltStrategy.js" import type * as Take from "./Take.js" import type * as Tracer from "./Tracer.js" import type { Covariant, MergeRecord, NoInfer } from "./Types.js" import type * as Unify from "./Unify.js" /** * @since 2.0.0 * @category symbols */ export const StreamTypeId: unique symbol = internal.StreamTypeId /** * @since 2.0.0 * @category symbols */ export type StreamTypeId = typeof StreamTypeId /** * A `Stream<A, E, R>` is a description of a program that, when evaluated, may * emit zero or more values of type `A`, may fail with errors of type `E`, and * uses an context of type `R`. One way to think of `Stream` is as a * `Effect` program that could emit multiple values. * * `Stream` is a purely functional *pull* based stream. Pull based streams offer * inherent laziness and backpressure, relieving users of the need to manage * buffers between operators. As an optimization, `Stream` does not emit * single values, but rather an array of values. This allows the cost of effect * evaluation to be amortized. * * `Stream` forms a monad on its `A` type parameter, and has error management * facilities for its `E` type parameter, modeled similarly to `Effect` (with * some adjustments for the multiple-valued nature of `Stream`). These aspects * allow for rich and expressive composition of streams. * * @since 2.0.0 * @category models */ export interface Stream<out A, out E = never, out R = never> extends Stream.Variance<A, E, R>, Pipeable { [Unify.typeSymbol]?: unknown [Unify.unifySymbol]?: StreamUnify<this> [Unify.ignoreSymbol]?: StreamUnifyIgnore } /** * @since 2.0.0 * @category models */ export interface StreamUnify<A extends { [Unify.typeSymbol]?: any }> extends Effect.EffectUnify<A> { Stream?: () => A[Unify.typeSymbol] extends Stream<infer A0, infer E0, infer R0> | infer _ ? Stream<A0, E0, R0> : never } /** * @category models * @since 2.0.0 */ export interface StreamUnifyIgnore extends Effect.EffectUnifyIgnore { Effect?: true } /** * @since 2.0.0 * @category models */ declare module "./Effect.js" { interface Effect<A, E, R> extends Stream<A, E, R> {} interface EffectUnifyIgnore { Stream?: true } } /** * @category type lambdas * @since 2.0.0 */ export interface StreamTypeLambda extends TypeLambda { readonly type: Stream<this["Target"], this["Out1"], this["Out2"]> } /** * @since 2.0.0 */ export declare namespace Stream { /** * @since 2.0.0 * @category models */ export interface Variance<out A, out E, out R> { readonly [StreamTypeId]: { _A: Covariant<A> _E: Covariant<E> _R: Covariant<R> } } /** * @since 2.0.0 * @category models */ export type DynamicTuple<T, N extends number> = N extends N ? number extends N ? Array<T> : DynamicTupleOf<T, N, []> : never /** * @since 2.0.0 * @category models */ export type DynamicTupleOf<T, N extends number, R extends Array<unknown>> = R["length"] extends N ? R : DynamicTupleOf<T, N, [T, ...R]> } /** * The default chunk size used by the various combinators and constructors of * `Stream`. * * @since 2.0.0 * @category constants */ export const DefaultChunkSize: number = internal.DefaultChunkSize /** * Collects each underlying Chunk of the stream into a new chunk, and emits it * on each pull. * * @since 2.0.0 * @category utils */ export const accumulate: <A, E, R>(self: Stream<A, E, R>) => Stream<Chunk.Chunk<A>, E, R> = internal.accumulate /** * Re-chunks the elements of the stream by accumulating each underlying chunk. * * @since 2.0.0 * @category utils */ export const accumulateChunks: <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R> = internal.accumulateChunks /** * Creates a stream from a single value that will get cleaned up after the * stream is consumed. * * @since 2.0.0 * @category constructors */ export const acquireRelease: <A, E, R, R2, X>( acquire: Effect.Effect<A, E, R>, release: (resource: A, exit: Exit.Exit<unknown, unknown>) => Effect.Effect<X, never, R2> ) => Stream<A, E, R | R2> = internal.acquireRelease /** * Aggregates elements of this stream using the provided sink for as long as * the downstream operators on the stream are busy. * * This operator divides the stream into two asynchronous "islands". Operators * upstream of this operator run on one fiber, while downstream operators run * on another. Whenever the downstream fiber is busy processing elements, the * upstream fiber will feed elements into the sink until it signals * completion. * * Any sink can be used here, but see `Sink.foldWeightedEffect` and * `Sink.foldUntilEffect` for sinks that cover the common usecases. * * @since 2.0.0 * @category utils */ export const aggregate: { <B, A, A2, E2, R2>(sink: Sink.Sink<B, A | A2, A2, E2, R2>): <E, R>(self: Stream<A, E, R>) => Stream<B, E2 | E, R2 | R> <A, E, R, B, A2, E2, R2>(self: Stream<A, E, R>, sink: Sink.Sink<B, A | A2, A2, E2, R2>): Stream<B, E | E2, R | R2> } = internal.aggregate /** * Like `aggregateWithinEither`, but only returns the `Right` results. * * @param sink A `Sink` used to perform the aggregation. * @param schedule A `Schedule` used to signal when to stop the aggregation. * @since 2.0.0 * @category utils */ export const aggregateWithin: { <B, A, A2, E2, R2, C, R3>( sink: Sink.Sink<B, A | A2, A2, E2, R2>, schedule: Schedule.Schedule<C, Option.Option<B>, R3> ): <E, R>(self: Stream<A, E, R>) => Stream<B, E2 | E, R2 | R3 | R> <A, E, R, B, A2, E2, R2, C, R3>( self: Stream<A, E, R>, sink: Sink.Sink<B, A | A2, A2, E2, R2>, schedule: Schedule.Schedule<C, Option.Option<B>, R3> ): Stream<B, E | E2, R | R2 | R3> } = internal.aggregateWithin /** * Aggregates elements using the provided sink until it completes, or until * the delay signalled by the schedule has passed. * * This operator divides the stream into two asynchronous islands. Operators * upstream of this operator run on one fiber, while downstream operators run * on another. Elements will be aggregated by the sink until the downstream * fiber pulls the aggregated value, or until the schedule's delay has passed. * * Aggregated elements will be fed into the schedule to determine the delays * between pulls. * * @param sink A `Sink` used to perform the aggregation. * @param schedule A `Schedule` used to signal when to stop the aggregation. * @since 2.0.0 * @category utils */ export const aggregateWithinEither: { <B, A, A2, E2, R2, C, R3>( sink: Sink.Sink<B, A | A2, A2, E2, R2>, schedule: Schedule.Schedule<C, Option.Option<B>, R3> ): <E, R>(self: Stream<A, E, R>) => Stream<Either.Either<B, C>, E2 | E, R2 | R3 | R> <A, E, R, B, A2, E2, R2, C, R3>( self: Stream<A, E, R>, sink: Sink.Sink<B, A | A2, A2, E2, R2>, schedule: Schedule.Schedule<C, Option.Option<B>, R3> ): Stream<Either.Either<B, C>, E | E2, R | R2 | R3> } = internal.aggregateWithinEither /** * Maps the success values of this stream to the specified constant value. * * @since 2.0.0 * @category mapping */ export const as: { <B>(value: B): <A, E, R>(self: Stream<A, E, R>) => Stream<B, E, R> <A, E, R, B>(self: Stream<A, E, R>, value: B): Stream<B, E, R> } = internal.as const _async: <A, E = never, R = never>( register: (emit: Emit.Emit<R, E, A, void>) => Effect.Effect<void, never, R> | void, outputBuffer?: number ) => Stream<A, E, R> = internal._async export { /** * Creates a stream from an asynchronous callback that can be called multiple * times. The optionality of the error type `E` in `Emit` can be used to * signal the end of the stream by setting it to `None`. * * The registration function can optionally return an `Effect`, which will be * executed if the `Fiber` executing this Effect is interrupted. * * @since 2.0.0 * @category constructors */ _async as async } /** * Creates a stream from an asynchronous callback that can be called multiple * times The registration of the callback itself returns an effect. The * optionality of the error type `E` can be used to signal the end of the * stream, by setting it to `None`. * * @since 2.0.0 * @category constructors */ export const asyncEffect: <A, E = never, R = never>( register: (emit: Emit.Emit<R, E, A, void>) => Effect.Effect<unknown, E, R>, outputBuffer?: number ) => Stream<A, E, R> = internal.asyncEffect /** * Creates a stream from an asynchronous callback that can be called multiple * times. The registration of the callback itself returns an a scoped * resource. The optionality of the error type `E` can be used to signal the * end of the stream, by setting it to `None`. * * @since 2.0.0 * @category constructors */ export const asyncScoped: <A, E = never, R = never>( register: (emit: Emit.Emit<R, E, A, void>) => Effect.Effect<unknown, E, R | Scope.Scope>, outputBuffer?: number ) => Stream<A, E, Exclude<R, Scope.Scope>> = internal.asyncScoped /** * Returns a `Stream` that first collects `n` elements from the input `Stream`, * and then creates a new `Stream` using the specified function, and sends all * the following elements through that. * * @since 2.0.0 * @category sequencing */ export const branchAfter: { <A, A2, E2, R2>( n: number, f: (input: Chunk.Chunk<A>) => Stream<A2, E2, R2> ): <E, R>(self: Stream<A, E, R>) => Stream<A2, E2 | E, R2 | R> <A, E, R, A2, E2, R2>( self: Stream<A, E, R>, n: number, f: (input: Chunk.Chunk<A>) => Stream<A2, E2, R2> ): Stream<A2, E | E2, R | R2> } = internal.branchAfter /** * Fan out the stream, producing a list of streams that have the same elements * as this stream. The driver stream will only ever advance the `maximumLag` * chunks before the slowest downstream stream. * * @since 2.0.0 * @category utils */ export const broadcast: { <N extends number>( n: N, maximumLag: number ): <A, E, R>( self: Stream<A, E, R> ) => Effect.Effect<Stream.DynamicTuple<Stream<A, E>, N>, never, Scope.Scope | R> <A, E, R, N extends number>( self: Stream<A, E, R>, n: N, maximumLag: number ): Effect.Effect<Stream.DynamicTuple<Stream<A, E>, N>, never, Scope.Scope | R> } = internal.broadcast /** * Fan out the stream, producing a dynamic number of streams that have the * same elements as this stream. The driver stream will only ever advance the * `maximumLag` chunks before the slowest downstream stream. * * @since 2.0.0 * @category utils */ export const broadcastDynamic: { (maximumLag: number): <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<Stream<A, E>, never, Scope.Scope | R> <A, E, R>(self: Stream<A, E, R>, maximumLag: number): Effect.Effect<Stream<A, E>, never, Scope.Scope | R> } = internal.broadcastDynamic /** * Converts the stream to a scoped list of queues. Every value will be * replicated to every queue with the slowest queue being allowed to buffer * `maximumLag` chunks before the driver is back pressured. * * Queues can unsubscribe from upstream by shutting down. * * @since 2.0.0 * @category utils */ export const broadcastedQueues: { <N extends number>( n: N, maximumLag: number ): <A, E, R>( self: Stream<A, E, R> ) => Effect.Effect<Stream.DynamicTuple<Queue.Dequeue<Take.Take<A, E>>, N>, never, R | Scope.Scope> <A, E, R, N extends number>( self: Stream<A, E, R>, n: N, maximumLag: number ): Effect.Effect<Stream.DynamicTuple<Queue.Dequeue<Take.Take<A, E>>, N>, never, Scope.Scope | R> } = internal.broadcastedQueues /** * Converts the stream to a scoped dynamic amount of queues. Every chunk will * be replicated to every queue with the slowest queue being allowed to buffer * `maximumLag` chunks before the driver is back pressured. * * Queues can unsubscribe from upstream by shutting down. * * @since 2.0.0 * @category utils */ export const broadcastedQueuesDynamic: { ( maximumLag: number ): <A, E, R>( self: Stream<A, E, R> ) => Effect.Effect<Effect.Effect<Queue.Dequeue<Take.Take<A, E>>, never, Scope.Scope>, never, R | Scope.Scope> <A, E, R>( self: Stream<A, E, R>, maximumLag: number ): Effect.Effect<Effect.Effect<Queue.Dequeue<Take.Take<A, E>>, never, Scope.Scope>, never, Scope.Scope | R> } = internal.broadcastedQueuesDynamic /** * Allows a faster producer to progress independently of a slower consumer by * buffering up to `capacity` elements in a queue. * * @note This combinator destroys the chunking structure. It's recommended to * use rechunk afterwards. Additionally, prefer capacities that are powers * of 2 for better performance. * @since 2.0.0 * @category utils */ export const buffer: { ( options: { readonly capacity: "unbounded" } | { readonly capacity: number readonly strategy?: "dropping" | "sliding" | "suspend" | undefined } ): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R> <A, E, R>( self: Stream<A, E, R>, options: { readonly capacity: "unbounded" } | { readonly capacity: number readonly strategy?: "dropping" | "sliding" | "suspend" | undefined } ): Stream<A, E, R> } = internal.buffer /** * Allows a faster producer to progress independently of a slower consumer by * buffering up to `capacity` chunks in a queue. * * @note Prefer capacities that are powers of 2 for better performance. * @since 2.0.0 * @category utils */ export const bufferChunks: { ( options: { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined } ): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R> <A, E, R>( self: Stream<A, E, R>, options: { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend" | undefined } ): Stream<A, E, R> } = internal.bufferChunks /** * Switches over to the stream produced by the provided function in case this * one fails with a typed error. * * @since 2.0.0 * @category error handling */ export const catchAll: { <E, A2, E2, R2>(f: (error: E) => Stream<A2, E2, R2>): <A, R>(self: Stream<A, E, R>) => Stream<A2 | A, E2, R2 | R> <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, f: (error: E) => Stream<A2, E2, R2>): Stream<A | A2, E2, R | R2> } = internal.catchAll /** * Switches over to the stream produced by the provided function in case this * one fails. Allows recovery from all causes of failure, including * interruption if the stream is uninterruptible. * * @since 2.0.0 * @category error handling */ export const catchAllCause: { <E, A2, E2, R2>( f: (cause: Cause.Cause<E>) => Stream<A2, E2, R2> ): <A, R>(self: Stream<A, E, R>) => Stream<A2 | A, E2, R2 | R> <A, E, R, A2, E2, R2>( self: Stream<A, E, R>, f: (cause: Cause.Cause<E>) => Stream<A2, E2, R2> ): Stream<A | A2, E2, R | R2> } = internal.catchAllCause /** * Switches over to the stream produced by the provided function in case this * one fails with some typed error. * * @since 2.0.0 * @category error handling */ export const catchSome: { <E, A2, E2, R2>( pf: (error: E) => Option.Option<Stream<A2, E2, R2>> ): <A, R>(self: Stream<A, E, R>) => Stream<A2 | A, E | E2, R2 | R> <A, E, R, A2, E2, R2>( self: Stream<A, E, R>, pf: (error: E) => Option.Option<Stream<A2, E2, R2>> ): Stream<A | A2, E | E2, R | R2> } = internal.catchSome /** * Switches over to the stream produced by the provided function in case this * one fails with an error matching the given `_tag`. * * @since 2.0.0 * @category error handling */ export const catchTag: { <K extends E["_tag"] & string, E extends { _tag: string }, A1, E1, R1>( k: K, f: (e: Extract<E, { _tag: K }>) => Stream<A1, E1, R1> ): <A, R>(self: Stream<A, E, R>) => Stream<A1 | A, E1 | Exclude<E, { _tag: K }>, R1 | R> <A, E extends { _tag: string }, R, K extends E["_tag"] & string, A1, E1, R1>( self: Stream<A, E, R>, k: K, f: (e: Extract<E, { _tag: K }>) => Stream<A1, E1, R1> ): Stream<A | A1, E1 | Exclude<E, { _tag: K }>, R | R1> } = internal.catchTag /** * Switches over to the stream produced by one of the provided functions, in * case this one fails with an error matching one of the given `_tag`'s. * * @since 2.0.0 * @category error handling */ export const catchTags: { < E extends { _tag: string }, Cases extends { [K in E["_tag"]]+?: (error: Extract<E, { _tag: K }>) => Stream<any, any, any> } >( cases: Cases ): <A, R>( self: Stream<A, E, R> ) => Stream< | A | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Stream.Variance<infer A, infer _E, infer _R> ? A : never }[keyof Cases], | Exclude<E, { _tag: keyof Cases }> | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Stream.Variance<infer _A, infer E, infer _R> ? E : never }[keyof Cases], | R | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Stream.Variance<infer _A, infer _E, infer R> ? R : never }[keyof Cases] > < A, E extends { _tag: string }, R, Cases extends { [K in E["_tag"]]+?: (error: Extract<E, { _tag: K }>) => Stream<any, any, any> } >( self: Stream<A, E, R>, cases: Cases ): Stream< | A | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Stream.Variance<infer _R, infer _E, infer A> ? A : never }[keyof Cases], | Exclude<E, { _tag: keyof Cases }> | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Stream.Variance<infer _R, infer E, infer _A> ? E : never }[keyof Cases], | R | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Stream.Variance<infer R, infer _E, infer _A> ? R : never }[keyof Cases] > } = internal.catchTags /** * Switches over to the stream produced by the provided function in case this * one fails with some errors. Allows recovery from all causes of failure, * including interruption if the stream is uninterruptible. * * @since 2.0.0 * @category error handling */ export const catchSomeCause: { <E, A2, E2, R2>( pf: (cause: Cause.Cause<E>) => Option.Option<Stream<A2, E2, R2>> ): <A, R>(self: Stream<A, E, R>) => Stream<A2 | A, E | E2, R2 | R> <A, E, R, A2, E2, R2>( self: Stream<A, E, R>, pf: (cause: Cause.Cause<E>) => Option.Option<Stream<A2, E2, R2>> ): Stream<A | A2, E | E2, R | R2> } = internal.catchSomeCause /** * Returns a new stream that only emits elements that are not equal to the * previous element emitted, using natural equality to determine whether two * elements are equal. * * @since 2.0.0 * @category utils */ export const changes: <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R> = internal.changes /** * Returns a new stream that only emits elements that are not equal to the * previous element emitted, using the specified function to determine whether * two elements are equal. * * @since 2.0.0 * @category utils */ export const changesWith: { <A>(f: (x: A, y: A) => boolean): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R> <A, E, R>(self: Stream<A, E, R>, f: (x: A, y: A) => boolean): Stream<A, E, R> } = internal.changesWith /** * Returns a new stream that only emits elements that are not equal to the * previous element emitted, using the specified effectual function to * determine whether two elements are equal. * * @since 2.0.0 * @category utils */ export const changesWithEffect: { <A, E2, R2>( f: (x: A, y: A) => Effect.Effect<boolean, E2, R2> ): <E, R>(self: Stream<A, E, R>) => Stream<A, E2 | E, R2 | R> <A, E, R, E2, R2>(self: Stream<A, E, R>, f: (x: A, y: A) => Effect.Effect<boolean, E2, R2>): Stream<A, E | E2, R | R2> } = internal.changesWithEffect /** * Exposes the underlying chunks of the stream as a stream of chunks of * elements. * * @since 2.0.0 * @category utils */ export const chunks: <A, E, R>(self: Stream<A, E, R>) => Stream<Chunk.Chunk<A>, E, R> = internal.chunks /** * Performs the specified stream transformation with the chunk structure of * the stream exposed. * * @since 2.0.0 * @category utils */ export const chunksWith: { <A, E, R, A2, E2, R2>( f: (stream: Stream<Chunk.Chunk<A>, E, R>) => Stream<Chunk.Chunk<A2>, E2, R2> ): (self: Stream<A, E, R>) => Stream<A2, E | E2, R | R2> <A, E, R, A2, E2, R2>( self: Stream<A, E, R>, f: (stream: Stream<Chunk.Chunk<A>, E, R>) => Stream<Chunk.Chunk<A2>, E2, R2> ): Stream<A2, E | E2, R | R2> } = internal.chunksWith /** * Combines the elements from this stream and the specified stream by * repeatedly applying the function `f` to extract an element using both sides * and conceptually "offer" it to the destination stream. `f` can maintain * some internal state to control the combining process, with the initial * state being specified by `s`. * * Where possible, prefer `Stream.combineChunks` for a more efficient * implementation. * * @since 2.0.0 * @category utils */ export const combine: { <A2, E2, R2, S, R3, E, A, R4, R5, A3>( that: Stream<A2, E2, R2>, s: S, f: ( s: S, pullLeft: Effect.Effect<A, Option.Option<E>, R3>, pullRight: Effect.Effect<A2, Option.Option<E2>, R4> ) => Effect.Effect<Exit.Exit<readonly [A3, S], Option.Option<E2 | E>>, never, R5> ): <R>(self: Stream<A, E, R>) => Stream<A3, E2 | E, R2 | R3 | R4 | R5 | R> <R, A2, E2, R2, S, R3, E, A, R4, R5, A3>( self: Stream<A, E, R>, that: Stream<A2, E2, R2>, s: S, f: ( s: S, pullLeft: Effect.Effect<A, Option.Option<E>, R3>, pullRight: Effect.Effect<A2, Option.Option<E2>, R4> ) => Effect.Effect<Exit.Exit<readonly [A3, S], Option.Option<E2 | E>>, never, R5> ): Stream<A3, E2 | E, R | R2 | R3 | R4 | R5> } = internal.combine /** * Combines the chunks from this stream and the specified stream by repeatedly * applying the function `f` to extract a chunk using both sides and * conceptually "offer" it to the destination stream. `f` can maintain some * internal state to control the combining process, with the initial state * being specified by `s`. * * @since 2.0.0 * @category utils */ export const combineChunks: { <A2, E2, R2, S, R3, E, A, R4, R5, A3>( that: Stream<A2, E2, R2>, s: S, f: ( s: S, pullLeft: Effect.Effect<Chunk.Chunk<A>, Option.Option<E>, R3>, pullRight: Effect.Effect<Chunk.Chunk<A2>, Option.Option<E2>, R4> ) => Effect.Effect<Exit.Exit<readonly [Chunk.Chunk<A3>, S], Option.Option<E2 | E>>, never, R5> ): <R>(self: Stream<A, E, R>) => Stream<A3, E2 | E, R2 | R3 | R4 | R5 | R> <R, A2, E2, R2, S, R3, E, A, R4, R5, A3>( self: Stream<A, E, R>, that: Stream<A2, E2, R2>, s: S, f: ( s: S, pullLeft: Effect.Effect<Chunk.Chunk<A>, Option.Option<E>, R3>, pullRight: Effect.Effect<Chunk.Chunk<A2>, Option.Option<E2>, R4> ) => Effect.Effect<Exit.Exit<readonly [Chunk.Chunk<A3>, S], Option.Option<E2 | E>>, never, R5> ): Stream<A3, E2 | E, R | R2 | R3 | R4 | R5> } = internal.combineChunks /** * Concatenates the specified stream with this stream, resulting in a stream * that emits the elements from this stream and then the elements from the * specified stream. * * @since 2.0.0 * @category utils */ export const concat: { <A2, E2, R2>(that: Stream<A2, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<A2 | A, E2 | E, R2 | R> <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<A | A2, E | E2, R | R2> } = internal.concat /** * Concatenates all of the streams in the chunk to one stream. * * @since 2.0.0 * @category constructors */ export const concatAll: <A, E, R>(streams: Chunk.Chunk<Stream<A, E, R>>) => Stream<A, E, R> = internal.concatAll /** * Composes this stream with the specified stream to create a cartesian * product of elements. The `that` stream would be run multiple times, for * every element in the `this` stream. * * See also `Stream.zip` for the more common point-wise variant. * * @since 2.0.0 * @category utils */ export const cross: { <A2, E2, R2>(that: Stream<A2, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<[A, A2], E2 | E, R2 | R> <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<[A, A2], E | E2, R | R2> } = internal.cross /** * Composes this stream with the specified stream to create a cartesian * product of elements, but keeps only elements from this stream. The `that` * stream would be run multiple times, for every element in the `this` stream. * * See also `Stream.zipLeft` for the more common point-wise variant. * * @since 2.0.0 * @category utils */ export const crossLeft: { <A2, E2, R2>(that: Stream<A2, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E2 | E, R2 | R> <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<A, E | E2, R | R2> } = internal.crossLeft /** * Composes this stream with the specified stream to create a cartesian * product of elements, but keeps only elements from the other stream. The * `that` stream would be run multiple times, for every element in the `this` * stream. * * See also `Stream.zipRight` for the more common point-wise variant. * * @since 2.0.0 * @category utils */ export const crossRight: { <A2, E2, R2>(that: Stream<A2, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<A2, E2 | E, R2 | R> <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<A2, E | E2, R | R2> } = internal.crossRight /** * Composes this stream with the specified stream to create a cartesian * product of elements with a specified function. The `that` stream would be * run multiple times, for every element in the `this` stream. * * See also `Stream.zipWith` for the more common point-wise variant. * * @since 2.0.0 * @category utils */ export const crossWith: { <B, E2, R2, A, C>( that: Stream<B, E2, R2>, f: (a: A, b: B) => C ): <E, R>(self: Stream<A, E, R>) => Stream<C, E2 | E, R2 | R> <A, E, R, B, E2, R2, C>( self: Stream<A, E, R>, that: Stream<B, E2, R2>, f: (a: A, b: B) => C ): Stream<C, E | E2, R | R2> } = internal.crossWith /** * Delays the emission of values by holding new values for a set duration. If * no new values arrive during that time the value is emitted, however if a * new value is received during the holding period the previous value is * discarded and the process is repeated with the new value. * * This operator is useful if you have a stream of "bursty" events which * eventually settle down and you only need the final event of the burst. For * example, a search engine may only want to initiate a search after a user * has paused typing so as to not prematurely recommend results. * * @since 2.0.0 * @category utils */ export const debounce: { (duration: Duration.DurationInput): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R> <A, E, R>(self: Stream<A, E, R>, duration: Duration.DurationInput): Stream<A, E, R> } = internal.debounce /** * The stream that dies with the specified defect. * * @since 2.0.0 * @category constructors */ export const die: (defect: unknown) => Stream<never> = internal.die /** * The stream that dies with the specified lazily evaluated defect. * * @since 2.0.0 * @category constructors */ export const dieSync: (evaluate: LazyArg<unknown>) => Stream<never> = internal.dieSync /** * The stream that dies with an exception described by `message`. * * @since 2.0.0 * @category constructors */ export const dieMessage: (message: string) => Stream<never> = internal.dieMessage /** * More powerful version of `Stream.broadcast`. Allows to provide a function * that determines what queues should receive which elements. The decide * function will receive the indices of the queues in the resulting list. * * @since 2.0.0 * @category utils */ export const distributedWith: { <N extends number, A>( options: { readonly size: N readonly maximumLag: number readonly decide: (a: A) => Effect.Effect<Predicate<number>> } ): <E, R>( self: Stream<A, E, R> ) => Effect.Effect<Stream.DynamicTuple<Queue.Dequeue<Exit.Exit<A, Option.Option<E>>>, N>, never, Scope.Scope | R> <A, E, R, N extends number>( self: Stream<A, E, R>, options: { readonly size: N readonly maximumLag: number readonly decide: (a: A) => Effect.Effect<Predicate<number>> } ): Effect.Effect<Stream.DynamicTuple<Queue.Dequeue<Exit.Exit<A, Option.Option<E>>>, N>, never, Scope.Scope | R> } = internal.distributedWith /** * More powerful version of `Stream.distributedWith`. This returns a function * that will produce new queues and corresponding indices. You can also * provide a function that will be executed after the final events are * enqueued in all queues. Shutdown of the queues is handled by the driver. * Downstream users can also shutdown queues manually. In this case the driver * will continue but no longer backpressure on them. * * @since 2.0.0 * @category utils */ export const distributedWithDynamic: { <A>( options: { readonly maximumLag: number; readonly decide: (a: A) => Effect.Effect<Predicate<number>, never, never> } ): <E, R>( self: Stream<A, E, R> ) => Effect.Effect< Effect.Effect<[number, Queue.Dequeue<Exit.Exit<A, Option.Option<E>>>], never, never>, never, Scope.Scope | R > <A, E, R>( self: Stream<A, E, R>, options: { readonly maximumLag: number; readonly decide: (a: A) => Effect.Effect<Predicate<number>, never, never> } ): Effect.Effect< Effect.Effect<[number, Queue.Dequeue<Exit.Exit<A, Option.Option<E>>>], never, never>, never, Scope.Scope | R > } = internal.distributedWithDynamic /** * Converts this stream to a stream that executes its effects but emits no * elements. Useful for sequencing effects using streams: * * @since 2.0.0 * @category utils */ export const drain: <A, E, R>(self: Stream<A, E, R>) => Stream<never, E, R> = internal.drain /** * Drains the provided stream in the background for as long as this stream is * running. If this stream ends before `other`, `other` will be interrupted. * If `other` fails, this stream will fail with that error. * * @since 2.0.0 * @category utils */ export const drainFork: { <A2, E2, R2>(that: Stream<A2, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E2 | E, R2 | R> <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<A, E | E2, R | R2> } = internal.drainFork /** * Drops the specified number of elements from this stream. * * @since 2.0.0 * @category utils */ export const drop: { (n: number): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R> <A, E, R>(self: Stream<A, E, R>, n: number): Stream<A, E, R> } = internal.drop /** * Drops the last specified number of elements from this stream. * * @note This combinator keeps `n` elements in memory. Be careful with big * numbers. * @since 2.0.0 * @category utils */ export const dropRight: { (n: number): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R> <A, E, R>(self: Stream<A, E, R>, n: number): Stream<A, E, R> } = internal.dropRight /** * Drops all elements of the stream until the specified predicate evaluates to * `true`. * * @since 2.0.0 * @category utils */ export const dropUntil: { <A>(predicate: Predicate<NoInfer<A>>): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R> <A, E, R>(self: Stream<A, E, R>, predicate: Predicate<A>): Stream<A, E, R> } = internal.dropUntil /** * Drops all elements of the stream until the specified effectful predicate * evaluates to `true`. * * @since 2.0.0 * @category utils */ export const dropUntilEffect: { <A, E2, R2>( predicate: (a: NoInfer<A>) => Effect.Effect<boolean, E2, R2> ): <E, R>(self: Stream<A, E, R>) => Stream<A, E2 | E, R2 | R> <A, E, R, E2, R2>( self: Stream<A, E, R>, predicate: (a: NoInfer<A>) => Effect.Effect<boolean, E2, R2> ): Stream<A, E | E2, R | R2> } = internal.dropUntilEffect /** * Drops all elements of the stream for as long as the specified predicate * evaluates to `true`. * * @since 2.0.0 * @category utils */ export const dropWhile: { <A>(predicate: Predicate<NoInfer<A>>): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R> <A, E, R>(self: Stream<A, E, R>, predicate: Predicate<A>): Stream<A, E, R> } = internal.dropWhile /** * Drops all elements of the stream for as long as the specified predicate * produces an effect that evalutates to `true` * * @since 2.0.0 * @category utils */ export const dropWhileEffect: { <A, E2, R2>( predicate: (a: NoInfer<A>) => Effect.Effect<boolean, E2, R2> ): <E, R>(self: Stream<A, E, R>) => Stream<A, E2 | E, R2 | R> <A, E, R, E2, R2>( self: Stream<A, E, R>, predicate: (a: A) => Effect.Effect<boolean, E2, R2> ): Stream<A, E | E2, R | R2> } = internal.dropWhileEffect /** * Returns a stream whose failures and successes have been lifted into an * `Either`. The resulting stream cannot fail, because the failures have been * exposed as part of the `Either` success case. * * @note The stream will end as soon as the first error occurs. * * @since 2.0.0 * @category utils */ export const either: <A, E, R>(self: Stream<A, E, R>) => Stream<Either.Either<A, E>, never, R> = internal.either /** * The empty stream. * * @since 2.0.0 * @category constructors */ export const empty: Stream<never> = internal.empty /** * Executes the provided finalizer after this stream's finalizers run. * * @since 2.0.0 * @category utils */ export const ensuring: { <X, R2>(finalizer: Effect.Effect<X, never, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R2 | R> <A, E, R, X, R2>(self: Stream<A, E, R>, finalizer: Effect.Effect<X, never, R2>): Stream<A, E, R | R2> } = internal.ensuring /** * Executes the provided finalizer after this stream's finalizers run. * * @since 2.0.0 * @category utils */ export const ensuringWith: { <E, R2>( finalizer: (exit: Exit.Exit<unknown, E>) => Effect.Effect<unknown, never, R2> ): <A, R>(self: Stream<A, E, R>) => Stream<A, E, R2 | R> <A, E, R, R2>( self: Stream<A, E, R>, finalizer: (exit: Exit.Exit<unknown, E>) => Effect.Effect<unknown, never, R2> ): Stream<A, E, R | R2> } = internal.ensuringWith /** * Accesses the whole context of the stream. * * @since 2.0.0 * @category context */ export const context: <R>() => Stream<Context.Context<R>, never, R> = internal.context /** * Accesses the context of the stream. * * @since 2.0.0 * @category context */ export const contextWith: <R, A>(f: (env: Context.Context<R>) => A) => Stream<A, never, R> = internal.contextWith /** * Accesses the context of the stream in the context of an effect. * * @since 2.0.0 * @category context */ export const contextWithEffect: <R0, A, E, R>( f: (env: Context.Context<R0>) => Effect.Effect<A, E, R> ) => Stream<A, E, R0 | R> = internal.contextWithEffect /** * Accesses the context of the stream in the context of a stream. * * @since 2.0.0 * @category context */ export const contextWithStream: <R0, A, E, R>( f: (env: Context.Context<R0>) => Stream<A, E, R> ) => Stream<A, E, R0 | R> = internal.contextWithStream /** * Creates a stream that executes the specified effect but emits no elements. * * @since 2.0.0 * @category constructors */ export const execute: <X, E, R>(effect: Effect.Effect<X, E, R>) => Stream<never, E, R> = internal.execute /** * Terminates with the specified error. * * @since 2.0.0 * @category constructors */ export const fail: <E>(error: E) => Stream<never, E> = internal.fail /** * Terminates with the specified lazily evaluated error. * * @since 2.0.0 * @category constructors */ export const failSync: <E>(evaluate: LazyArg<E>) => Stream<never, E> = internal.failSync /** * The stream that always fails with the specified `Cause`. * * @since 2.0.0 * @category constructors */ export const failCause: <E>(cause: Cause.Cause<E>) => Stream<never, E> = internal.failCause /** * The stream that always fails with the specified lazily evaluated `Cause`. * * @since 2.0.0 * @category constructors */ export const failCauseSync: <E>(evaluate: LazyArg<Cause.Cause<E>>) => Stream<never, E> = internal.failCauseSync /** * Filters the elements emitted by this stream using the provided function. * * @since 2.0.0 * @category filtering */ export const filter: { <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R> <A, B extends A>(predicate: Predicate<B>): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R> <A, E, R, B extends A>(self: Stream<A, E, R>, refinement: Refinement<A, B>): Stream<B, E, R> <A, E, R>(self: Stream<A, E, R>, predicate: Predicate<A>): Stream<A, E, R> } = internal.filter /** * Effectfully filters the elements emitted by this stream. * * @since 2.0.0 * @category filtering */ export const filterEffect: { <A, E2, R2>( f: (a: NoInfer<A>) => Effect.Effect<boolean, E2, R2> ): <E, R>(self: Stream<A, E, R>) => Stream<A, E2 | E, R2 | R> <A, E, R, E2, R2>(self: Stream<A, E, R>, f: (a: A) => Effect.Effect<boolean, E2, R2>): Stream<A, E | E2, R | R2> } = internal.filterEffect /** * Performs a filter and map in a single step. * * @since 2.0.0 * @category utils */ export const filterMap: { <A, B>(pf: (a: A) => Option.Option<B>): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R> <A, E, R, B>(self: Stream<A, E, R>, pf: (a: A) => Option.Option<B>): Stream<B, E, R> } = internal.filterMap /** * Performs an effectful filter and map in a single step. * * @since 2.0.0 * @category utils */ export const filterMapEffect: { <A, A2, E2, R2>( pf: (a: A) => Option.Option<Effect.Effect<A2, E2, R2>> ): <E, R>(self: Stream<A, E, R>) => Stream<A2, E2 | E, R2 | R> <A, E, R, A2, E2, R2>( self: Stream<A, E, R>, pf: (a: A) => Option.Option<Effect.Effect<A2, E2, R2>> ): Stream<A2, E | E2, R | R2> } = internal.filterMapEffect /** * Transforms all elements of the stream for as long as the specified partial * function is defined. * * @since 2.0.0 * @category utils */ export const filterMapWhile: { <A, A2>(pf: (a: A) => Option.Option<A2>): <E, R>(self: Stream<A, E, R>) => Stream<A2, E, R> <A, E, R, A2>(self: Stream<A, E, R>, pf: (a: A) => Option.Option<A2>): Stream<A2, E, R> } = internal.filterMapWhile /** * Effectfully transforms all elements of the stream for as long as the * specified partial function is defined. * * @since 2.0.0 * @category utils */ export const filterMapWhileEffect: { <A, A2, E2, R2>( pf: (a: A) => Option.Option<Effect.Effect<A2, E2, R2>> ): <E, R>(self: Stream<A, E, R>) => Stream<A2, E2 | E, R2 | R> <A, E, R, A2, E2, R2>( self: Stream<A, E, R>, pf: (a: A) => Option.Option<Effect.Effect<A2, E2, R2>> ): Stream<A2, E | E2, R | R2> } = internal.filterMapWhileEffect /** * Creates a one-element stream that never fails and executes the finalizer * when it ends. * * @since 2.0.0 * @category constructors */ export const finalizer: <R, X>(finalizer: Effect.Effect<X, never, R>) => Stream<void, never, R> = internal.finalizer /** * Finds the first element emitted by this stream that satisfies the provided * predicate. * * @since 2.0.0 * @category elements */ export const find: { <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): <E, R>(self: Stream<A, E, R>) => Stream<B, E, R> <A>(predicate: Predicate<NoInfer<A>>): <E, R>(self: Stream<A, E, R>) => Stream<A, E, R> <A, E, R, B extends A>(self: Stream<A, E, R>, refinement: Refinement<A, B>): Stream<B, E, R> <A, E, R>(self: Stream<A, E, R>, predicate: Predicate<A>): Stream<A, E, R> } = internal.find /** * Finds the first element emitted by this stream that satisfies the provided * effectful predicate. * * @since 2.0.0 * @category elements */ export const findEffect: { <A, E2, R2>( predicate: (a: NoInfer<A>) => Effect.Effect<boolean, E2, R2> ): <E, R>(self: Stream<A, E, R>) => Stream<A, E2 | E, R2 | R> <A, E, R, E2, R2>( self: Stream<A, E, R>, predicate: (a: NoInfer<A>) => Effect.Effect<boolean, E2, R2> ): Stream<A, E | E2, R | R2> } = internal.findEffect /** * Returns a stream made of the concatenation in strict order of all the * streams produced by passing each element of this stream to `f0` * * @since 2.0.0 * @category sequencing */ export const flatMap: { <A, A2, E2, R2>( f: (a: A) => Stream<A2, E2, R2>, options?: { readonly concurrency?: number | "unbounded" | undefined readonly bufferSize?: number | undefined readonly switch?: boolean | undefined } | undefined ): <E, R>(self: Stream<A, E, R>) => Stream<A2, E2 | E, R2 | R> <A, E, R, A2, E2, R2>( self: Stream<A, E, R>, f: (a: A) => Stream<A2, E2, R2>, options?: { readonly concurrency?: number | "unbounded" | undefined readonly bufferSize?: number | undefined readonly switch?: boolean | undefined } | undefined ): Stream<A2, E | E2, R | R2> } = internal.flatMap /** * Flattens this stream-of-streams into a stream made of the concatenation in * strict order of all the streams. * * @since 2.0.0 * @category sequencing */ export const flatten: { ( options?: | { readonly concurrency?: number | "unbounded" | undefined; readonly bufferSize?: number | undefined } | undefined ): <A, E2, R2, E, R>(self: Stream<Stream<A, E2, R2>, E, R>) => Stream<A, E2 | E, R2 | R> <A, E2, R2, E, R>( self: Stream<Stream<A, E2, R2>, E, R>, options?: | { readonly concurrency?: number | "unbounded" | undefined; readonly bufferSize?: number | undefined } | undefined ): Stream<A, E2 | E, R2 | R> } = internal.flatten /** * Submerges the chunks carried by this stream into the stream's structure, * while still preserving them. * * @since 2.0.0 * @category sequencing */ export const flattenChunks: <A, E, R>(self: Stream<Chunk.Chunk<A>, E, R>) => Stream<A, E, R> = internal.flattenChunks /** * Flattens `Effect` values into the stream's structure, preserving all * information about the effect. * * @since 2.0.0 * @category sequencing */ export const flattenEffect: { ( options?: | { readonly concurrency?: number | "unbounded" | undefined; readonly unordered?: boolean | undefined } | undefined ): <A, E2, R2, E, R>(self: Stream<Effect.Effect<A, E2, R2>, E, R>) => Stream<A, E2 | E, R2 | R> <A, E2, R2, E, R>( self: Stream<Effect.Effect<A, E2, R2>, E, R>, options?: | { readonly concurrency?: number | "unbounded" | undefined; readonly unordered?: boolean | undefined } | undefined ): Stream<A, E2 | E, R2 | R> } = internal.flattenEffect /** * Unwraps `Exit` values that also signify end-of-stream by failing with `None`. * * For `Exit` values that do not signal end-of-stream, prefer: * * ```ts * stream.mapZIO(ZIO.done(_)) * ``` * * @since 2.0.0 * @category sequencing */ export const flattenExitOption: <A, E2, E, R>( self: Stream<Exit.Exit<A, Option.Option<E2>>, E, R> ) => Stream<A, E | E2, R> = internal.flattenExitOption /** * Submerges the iterables carried by this stream into the stream's structure, * while still preserving them. * * @since 2.0.0 * @category sequencing */ export const flattenIterables: <A, E, R>(self: Stream<Iterable<A>, E, R>) => Stream<A, E, R> = internal.flattenIterables /** * Unwraps `Exit` values and flatten chunks that also signify end-of-stream * by failing with `None`. * * @since 2.0.0 * @category sequencing */ export const flattenTake: <A, E2, E, R>(self: Stream<Take.Take<A, E2>, E, R>) => Stream<A, E | E2, R> = internal.flattenTake /** * Repeats this stream forever. * * @since 2.0.0 * @category utils */ export const forever: <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R> = internal.forever /** * Creates a stream from an `AsyncIterable`. * * @since 2.0.0 * @category constructors */ export const fromAsyncIterable: <A, E>(iterable: AsyncIterable<A>, onError: (e: unknown) => E) => Stream<A, E> = internal.fromAsyncIterable /** * Creates a stream from a `Channel`. * * @since 2.0.0 * @category constructors */ export const fromChannel: <A, E, R>( channel: Channel.Channel<Chunk.Chunk<A>, unknown, E, unknown, unknown, unknown, R> ) => Stream<A, E, R> = internal.fromChannel /** * Creates a channel from a `Stream`. * * @since 2.0.0 * @category constructors */ export const toChannel: <A, E, R>( stream: Stream<A, E, R> ) => Channel.Channel<Chunk.Chunk<A>, unknown, E, unknown, unknown, unknown, R> = internal.toChannel /** * Creates a stream from a `Chunk` of values. * * @since 2.0.0 * @category constructors */ export const fromChunk: <A>(chunk: Chunk.Chunk<A>) => Stream<A> = internal.fromChunk /** * Creates a stream from a subscription to a `PubSub`. * * @param shutdown If `true`, the `PubSub` will be shutdown after the stream is evaluated (defaults to `false`) * @since 2.0.0 * @category constructors */ export const fromChunkPubSub: { <A>( pubsub: PubSub.PubSub<Chunk.Chunk<A>>, options: { readonly scoped: true; readonly shutdown?: boolean | undefined } ): Effect.Effect<Stream<A>, never, Scope.Scope> <A>( pubsub: PubSub.PubSub<Chunk.Chunk<A>>, options?: { readonly scoped?: false | undefined; readonly shutdown?: boolean | undefined } | undefined ): Stream<A> } = internal.fromChunkPubSub /** * Creates a stream from a `Queue` of values. * * @param shutdown If `true`, the queue will be shutdown after the stream is evaluated (defaults to `false`) * @since 2.0.0 * @category constructors */ export const fromChunkQueue: <A>( queue: Queue.Dequeue<Chunk.Chunk<A>>, options?: { readonly shutdown?: boolean | undefined } ) => Stream<A> = internal.fromChunkQueue /** * Creates a stream from an arbitrary number of chunks. * * @since 2.0.0 * @category constructors */ export const fromChunks: <A>(...chunks: Array<Chunk.Chunk<A>>) => Stream<A> = internal.fromChunks /** * Either emits the success value of this effect or terminates the stream * with the failure value of this effect. * * @since 2.0.0 * @category constructors */ export const fromEffect: <A, E, R>(effect: Effect.Effect<A, E, R>) => Stream<A, E, R> = internal.fromEffect /** * Creates a stream from an effect producing a value of type `A` or an empty * `Stream`. * * @since 2.0.0 * @category constructors */ export const fromEffectOption: <A, E, R>(effect: Effect.Effect<A, Option.Option<E>, R>) => Stream<A, E, R> = internal.fromEffectOption /** * Creates a stream from a subscription to a `PubSub`. * * @param shutdown If `true`, the `PubSub` will be shutdown after the stream is evaluated (defaults to `false`) * @since 2.0.0 * @category constructors */ export const fromPubSub: { <A>( pubsub: PubSub.PubSub<A>, options: { readonly scoped: true readonly maxChunkSize?: number | undefined readonly shutdown?: boolean | undefined } ): Effect.Effect<Stream<A>, never, Scope.Scope> <A>( pubsub: PubSub.PubSub<A>, options?: { readonly scoped?: false | undefined readonly maxChunkSize?: number | undefined readonly shutdown?: boolean | undefined } | undefined ): Stream<A> } = internal.fromPubSub /** * Creates a new `Stream` from an iterable collection of values. * * @since 2.0.0 * @category constructors */ export const fromIterable: <A>(iterable: Iterable<A>) => Stream<A> = internal.fromIterable /** * Creates a stream from an effect producing a value of type `Iterable<A>`. * * @since 2.0.0 * @category constructors */ export const fromIterableEffect: <A, E, R>(effect: Effect.Effect<Iterable<A>, E, R>) => Stream<A, E, R> = internal.fromIterableEffect /** * Creates a stream from an iterator * * @since 2.0.0 * @category constructors */ export const fromIteratorSucceed: <A>(iterator: IterableIterator<A>, maxChunkSize?: number) => Stream<A> = internal.fromIteratorSucceed /** * Creates a stream from an effect that pulls elements from another stream. * * See `Stream.toPull` for reference. * * @since 2.0.0 * @category constructors */ export const fromPull: <R, R2, E, A>( effect: Effect.Effect<Effect.Effect<Chunk.Chunk<A>, Option.Option<E>, R2>, never, Scope.Scope | R> ) => Stream<A, E, R2 | Exclude<R, Scope.Scope>> = internal.fromPull /** * Creates a stream from a queue of values * * @param maxChunkSize The maximum number of queued elements to put in one chunk in the stream * @param shutdown If `true`, the queue will be shutdown after the stream is evaluated (defaults to `false`) * @since 2.0.0 * @category constructors */ export const fromQueue: <A>( queue: Qu