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,272 lines • 141 kB
TypeScript
/**
* @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 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 declare const StreamTypeId: unique symbol;
/**
* @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
*/
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
*/
type DynamicTuple<T, N extends number> = N extends N ? number extends N ? Array<T> : DynamicTupleOf<T, N, []> : never;
/**
* @since 2.0.0
* @category models
*/
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 declare const DefaultChunkSize: number;
/**
* Collects each underlying Chunk of the stream into a new chunk, and emits it
* on each pull.
*
* @since 2.0.0
* @category utils
*/
export declare const accumulate: <A, E, R>(self: Stream<A, E, R>) => Stream<Chunk.Chunk<A>, E, R>;
/**
* Re-chunks the elements of the stream by accumulating each underlying chunk.
*
* @since 2.0.0
* @category utils
*/
export declare const accumulateChunks: <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>;
/**
* Creates a stream from a single value that will get cleaned up after the
* stream is consumed.
*
* @since 2.0.0
* @category constructors
*/
export declare 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>;
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* Maps the success values of this stream to the specified constant value.
*
* @since 2.0.0
* @category mapping
*/
export declare 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>;
};
declare 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>;
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 declare 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>;
/**
* 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 declare 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>>;
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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]>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare const changes: <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>;
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* Exposes the underlying chunks of the stream as a stream of chunks of
* elements.
*
* @since 2.0.0
* @category utils
*/
export declare const chunks: <A, E, R>(self: Stream<A, E, R>) => Stream<Chunk.Chunk<A>, E, R>;
/**
* Performs the specified stream transformation with the chunk structure of
* the stream exposed.
*
* @since 2.0.0
* @category utils
*/
export declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* Concatenates all of the streams in the chunk to one stream.
*
* @since 2.0.0
* @category constructors
*/
export declare const concatAll: <A, E, R>(streams: Chunk.Chunk<Stream<A, E, R>>) => Stream<A, E, R>;
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* The stream that dies with the specified defect.
*
* @since 2.0.0
* @category constructors
*/
export declare const die: (defect: unknown) => Stream<never>;
/**
* The stream that dies with the specified lazily evaluated defect.
*
* @since 2.0.0
* @category constructors
*/
export declare const dieSync: (evaluate: LazyArg<unknown>) => Stream<never>;
/**
* The stream that dies with an exception described by `message`.
*
* @since 2.0.0
* @category constructors
*/
export declare const dieMessage: (message: string) => Stream<never>;
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare const drain: <A, E, R>(self: Stream<A, E, R>) => Stream<never, E, R>;
/**
* 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 declare 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>;
};
/**
* Drops the specified number of elements from this stream.
*
* @since 2.0.0
* @category utils
*/
export declare 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>;
};
/**
* 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 declare 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>;
};
/**
* Drops all elements of the stream until the specified predicate evaluates to
* `true`.
*
* @since 2.0.0
* @category utils
*/
export declare 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>;
};
/**
* Drops all elements of the stream until the specified effectful predicate
* evaluates to `true`.
*
* @since 2.0.0
* @category utils
*/
export declare 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>;
};
/**
* Drops all elements of the stream for as long as the specified predicate
* evaluates to `true`.
*
* @since 2.0.0
* @category utils
*/
export declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare const either: <A, E, R>(self: Stream<A, E, R>) => Stream<Either.Either<A, E>, never, R>;
/**
* The empty stream.
*
* @since 2.0.0
* @category constructors
*/
export declare const empty: Stream<never>;
/**
* Executes the provided finalizer after this stream's finalizers run.
*
* @since 2.0.0
* @category utils
*/
export declare 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>;
};
/**
* Executes the provided finalizer after this stream's finalizers run.
*
* @since 2.0.0
* @category utils
*/
export declare 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>;
};
/**
* Accesses the whole context of the stream.
*
* @since 2.0.0
* @category context
*/
export declare const context: <R>() => Stream<Context.Context<R>, never, R>;
/**
* Accesses the context of the stream.
*
* @since 2.0.0
* @category context
*/
export declare const contextWith: <R, A>(f: (env: Context.Context<R>) => A) => Stream<A, never, R>;
/**
* Accesses the context of the stream in the context of an effect.
*
* @since 2.0.0
* @category context
*/
export declare const contextWithEffect: <R0, A, E, R>(f: (env: Context.Context<R0>) => Effect.Effect<A, E, R>) => Stream<A, E, R0 | R>;
/**
* Accesses the context of the stream in the context of a stream.
*
* @since 2.0.0
* @category context
*/
export declare const contextWithStream: <R0, A, E, R>(f: (env: Context.Context<R0>) => Stream<A, E, R>) => Stream<A, E, R0 | R>;
/**
* Creates a stream that executes the specified effect but emits no elements.
*
* @since 2.0.0
* @category constructors
*/
export declare const execute: <X, E, R>(effect: Effect.Effect<X, E, R>) => Stream<never, E, R>;
/**
* Terminates with the specified error.
*
* @since 2.0.0
* @category constructors
*/
export declare const fail: <E>(error: E) => Stream<never, E>;
/**
* Terminates with the specified lazily evaluated error.
*
* @since 2.0.0
* @category constructors
*/
export declare const failSync: <E>(evaluate: LazyArg<E>) => Stream<never, E>;
/**
* The stream that always fails with the specified `Cause`.
*
* @since 2.0.0
* @category constructors
*/
export declare const failCause: <E>(cause: Cause.Cause<E>) => Stream<never, E>;
/**
* The stream that always fails with the specified lazily evaluated `Cause`.
*
* @since 2.0.0
* @category constructors
*/
export declare const failCauseSync: <E>(evaluate: LazyArg<Cause.Cause<E>>) => Stream<never, E>;
/**
* Filters the elements emitted by this stream using the provided function.
*
* @since 2.0.0
* @category filtering
*/
export declare 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>;
};
/**
* Effectfully filters the elements emitted by this stream.
*
* @since 2.0.0
* @category filtering
*/
export declare 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>;
};
/**
* Performs a filter and map in a single step.
*
* @since 2.0.0
* @category utils
*/
export declare 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>;
};
/**
* Performs an effectful filter and map in a single step.
*
* @since 2.0.0
* @category utils
*/
export declare 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>;
};
/**
* Transforms all elements of the stream for as long as the specified partial
* function is defined.
*
* @since 2.0.0
* @category utils
*/
export declare 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>;
};
/**
* Effectfully transforms all elements of the stream for as long as the
* specified partial function is defined.
*
* @since 2.0.0
* @category utils
*/
export declare 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>;
};
/**
* Creates a one-element stream that never fails and executes the finalizer
* when it ends.
*
* @since 2.0.0
* @category constructors
*/
export declare const finalizer: <R, X>(finalizer: Effect.Effect<X, never, R>) => Stream<void, never, R>;
/**
* Finds the first element emitted by this stream that satisfies the provided
* predicate.
*
* @since 2.0.0
* @category elements
*/
export declare 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>;
};
/**
* Finds the first element emitted by this stream that satisfies the provided
* effectful predicate.
*
* @since 2.0.0
* @category elements
*/
export declare 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>;
};
/**
* 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 declare 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>;
};
/**
* 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 declare 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>;
};
/**
* Submerges the chunks carried by this stream into the stream's structure,
* while still preserving them.
*
* @since 2.0.0
* @category sequencing
*/
export declare const flattenChunks: <A, E, R>(self: Stream<Chunk.Chunk<A>, E, R>) => Stream<A, E, R>;
/**
* Flattens `Effect` values into the stream's structure, preserving all
* information about the effect.
*
* @since 2.0.0
* @category sequencing
*/
export declare 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>;
};
/**
* 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 declare const flattenExitOption: <A, E2, E, R>(self: Stream<Exit.Exit<A, Option.Option<E2>>, E, R>) => Stream<A, E | E2, R>;
/**
* Submerges the iterables carried by this stream into the stream's structure,
* while still preserving them.
*
* @since 2.0.0
* @category sequencing
*/
export declare const flattenIterables: <A, E, R>(self: Stream<Iterable<A>, E, R>) => Stream<A, E, R>;
/**
* Unwraps `Exit` values and flatten chunks that also signify end-of-stream
* by failing with `None`.
*
* @since 2.0.0
* @category sequencing
*/
export declare const flattenTake: <A, E2, E, R>(self: Stream<Take.Take<A, E2>, E, R>) => Stream<A, E | E2, R>;
/**
* Repeats this stream forever.
*
* @since 2.0.0
* @category utils
*/
export declare const forever: <A, E, R>(self: Stream<A, E, R>) => Stream<A, E, R>;
/**
* Creates a stream from an `AsyncIterable`.
*
* @since 2.0.0
* @category constructors
*/
export declare const fromAsyncIterable: <A, E>(iterable: AsyncIterable<A>, onError: (e: unknown) => E) => Stream<A, E>;
/**
* Creates a stream from a `Channel`.
*
* @since 2.0.0
* @category constructors
*/
export declare const fromChannel: <A, E, R>(channel: Channel.Channel<Chunk.Chunk<A>, unknown, E, unknown, unknown, unknown, R>) => Stream<A, E, R>;
/**
* Creates a channel from a `Stream`.
*
* @since 2.0.0
* @category constructors
*/
export declare const toChannel: <A, E, R>(stream: Stream<A, E, R>) => Channel.Channel<Chunk.Chunk<A>, unknown, E, unknown, unknown, unknown, R>;
/**
* Creates a stream from a `Chunk` of values.
*
* @since 2.0.0
* @category constructors
*/
export declare const fromChunk: <A>(chunk: Chunk.Chunk<A>) => Stream<A>;
/**
* 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 declare 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>;
};
/**
* 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 declare const fromChunkQueue: <A>(queue: Queue.Dequeue<Chunk.Chunk<A>>, options?: {
readonly shutdown?: boolean | undefined;
}) => Stream<A>;
/**
* Creates a stream from an arbitrary number of chunks.
*
* @since 2.0.0
* @category constructors
*/
export declare const fromChunks: <A>(...chunks: Array<Chunk.Chunk<A>>) => Stream<A>;
/**
* 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 declare const fromEffect: <A, E, R>(effect: Effect.Effect<A, E, R>) => Stream<A, E, R>;
/**
* Creates a stream from an effect producing a value of type `A` or an empty
* `Stream`.
*
* @since 2.0.0
* @category constructors
*/
export declare const fromEffectOption: <A, E, R>(effect: Effect.Effect<A, Option.Option<E>, R>) => Stream<A, E, R>;
/**
* 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 declare 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>;
};
/**
* Creates a new `Stream` from an iterable collection of values.
*
* @since 2.0.0
* @category constructors
*/
export declare const fromIterable: <A>(iterable: Iterable<A>) => Stream<A>;
/**
* Creates a stream from an effect producing a value of type `Iterable<A>`.
*
* @since 2.0.0
* @category constructors
*/
export declare const fromIterableEffect: <A, E, R>(effect: Effect.Effect<Iterable<A>, E, R>) => Stream<A, E, R>;
/**
* Creates a stream from an iterator
*
* @since 2.0.0
* @category constructors
*/
export declare const fromIteratorSucceed: <A>(iterator: IterableIterator<A>, maxChunkSize?: number) => Stream<A>;
/**
* Creates a stream from an effect that pulls elements from another stream.
*
* See `Stream.toPull` for reference.
*
* @since 2.0.0
* @category constructors
*/
export declare 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>>;
/**
* 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 declare const fromQueue: <A>(queue: Queue.Dequeue<A>, options?: {
readonly maxChunkSize?: number | undefined;
readonly shutdown?: boolean | undefined;
}) => Stream<A>;
/**
* Creates a stream from a `ReadableStream`.
*
* See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream.
*
* @since 2.0.0
* @category constructors
*/
export declare const fromReadableStream: <A, E>(evaluate: LazyArg<ReadableStream<A>>, onError: (error: unknown) => E) => Stream<A, E>;
/**
* Creates a stream from a `ReadableStreamBYOBReader`.
*
* See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader.
*
* @param allocSize Controls the size of the underlying `ArrayBuffer` (defaults to `4096`).
* @since 2.0.0
* @category constructors
*/
export declare const fromReadableStreamByob: <E>(evaluate: LazyArg<ReadableStream<Uint8Array>>, onError: (error: unknown) => E, allocSize?: number) => Stream<Uint8Array, E>;
/**
* Creates a stream from a `Schedule` that does not require any further
* input. The stream will emit an element for each value output from the
* schedule, continuing for as long as the schedule continues.
*
* @since 2.0.0
* @category constructors
*/
export declare const fromSchedule: <A, R>(schedule: Schedule.Schedule<A, unknown, R>) => Stream<A, never, R>;
/**
* Creates a pipeline that groups on adjacent keys, calculated by the
* specified function.
*
* @since 2.0.0
* @category grouping
*/
export declare const groupAdjacentBy: {
<A, K>(f: (a: A) => K): <E, R>(self: Stream<A, E, R>) => Stream<[K, Chunk.NonEmptyChunk<A>], E, R>;
<A, E, R, K>(self: Stream<A, E, R>, f: (a: A) => K): Stream<[K, Chunk.NonEmptyChunk<A>], E, R>;
};
/**
* More powerful version of `Stream.groupByKey`.
*
* @since 2.0.0
* @category grouping
*/
export declare con