/** * @since 1.0.0 */ import type * as Chunk from "@effect/data/Chunk"; import type * as Context from "@effect/data/Context"; import type * as Duration from "@effect/data/Duration"; import type * as Either from "@effect/data/Either"; import type { LazyArg } from "@effect/data/Function"; import type { TypeLambda } from "@effect/data/HKT"; import type * as Option from "@effect/data/Option"; import type * as Order from "@effect/data/Order"; import type { Pipeable } from "@effect/data/Pipeable"; import type { Predicate, Refinement } from "@effect/data/Predicate"; import type * as Unify from "@effect/data/Unify"; import type * as Cause from "@effect/io/Cause"; import type * as Deferred from "@effect/io/Deferred"; import type * as Effect from "@effect/io/Effect"; import type * as Exit from "@effect/io/Exit"; import type * as Hub from "@effect/io/Hub"; import type * as Layer from "@effect/io/Layer"; import type * as Queue from "@effect/io/Queue"; import type * as Schedule from "@effect/io/Schedule"; import type * as Scope from "@effect/io/Scope"; import type * as Tracer from "@effect/io/Tracer"; import type * as Channel from "@effect/stream/Channel"; import type * as GroupBy from "@effect/stream/GroupBy"; import type * as Sink from "@effect/stream/Sink"; import type * as Emit from "@effect/stream/Stream/Emit"; import type * as HaltStrategy from "@effect/stream/Stream/HaltStrategy"; import type * as Take from "@effect/stream/Take"; /** * @since 1.0.0 * @category symbols */ export declare const StreamTypeId: unique symbol; /** * @since 1.0.0 * @category symbols */ export type StreamTypeId = typeof StreamTypeId; /** * A `Stream` 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 1.0.0 * @category models */ export interface Stream extends Stream.Variance, Pipeable { [Unify.typeSymbol]?: unknown; [Unify.unifySymbol]?: StreamUnify; [Unify.blacklistSymbol]?: StreamUnifyBlacklist; } /** * @since 1.0.0 * @category models */ export interface StreamUnify extends Effect.EffectUnify { Stream?: () => A[Unify.typeSymbol] extends Stream | infer _ ? Stream : never; } /** * @category models * @since 1.0.0 */ export interface StreamUnifyBlacklist extends Effect.EffectUnifyBlacklist { Effect?: true; } /** * @since 1.0.0 * @category models */ declare module "@effect/io/Effect" { interface Effect extends Stream { } interface EffectUnifyBlacklist { Stream?: true; } } /** * @category type lambdas * @since 1.0.0 */ export interface StreamTypeLambda extends TypeLambda { readonly type: Stream; } /** * @since 1.0.0 */ export declare namespace Stream { /** * @since 1.0.0 * @category models */ interface Variance { readonly [StreamTypeId]: { _R: (_: never) => R; _E: (_: never) => E; _A: (_: never) => A; }; } /** * @since 1.0.0 * @category models */ type DynamicTuple = N extends N ? number extends N ? Array : DynamicTupleOf : never; /** * @since 1.0.0 * @category models */ type DynamicTupleOf> = R["length"] extends N ? R : DynamicTupleOf; } /** * The default chunk size used by the various combinators and constructors of * `Stream`. * * @since 1.0.0 * @category constants */ export declare const DefaultChunkSize: number; /** * Creates a stream from a single value that will get cleaned up after the * stream is consumed. * * @since 1.0.0 * @category constructors */ export declare const acquireRelease: (acquire: Effect.Effect, release: (resource: A, exit: Exit.Exit) => Effect.Effect) => Stream; /** * 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 1.0.0 * @category utils */ export declare const aggregate: { (sink: Sink.Sink): (self: Stream) => Stream; (self: Stream, sink: Sink.Sink): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const aggregateWithin: { (sink: Sink.Sink, schedule: Schedule.Schedule, C>): (self: Stream) => Stream; (self: Stream, sink: Sink.Sink, schedule: Schedule.Schedule, C>): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const aggregateWithinEither: { (sink: Sink.Sink, schedule: Schedule.Schedule, C>): (self: Stream) => Stream>; (self: Stream, sink: Sink.Sink, schedule: Schedule.Schedule, C>): Stream>; }; /** * Maps the success values of this stream to the specified constant value. * * @since 1.0.0 * @category mapping */ export declare const as: { (value: B): (self: Stream) => Stream; (self: Stream, value: B): Stream; }; declare const _async: (register: (emit: Emit.Emit) => void, outputBuffer?: number) => Stream; export { /** * Creates a stream from an asynchronous callback that can be called multiple * times. The optionality of the error type `E` can be used to signal the end * of the stream, by setting it to `None`. * * @since 1.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 1.0.0 * @category constructors */ export declare const asyncEffect: (register: (emit: Emit.Emit) => Effect.Effect, outputBuffer?: number) => Stream; /** * Creates a stream from an asynchronous callback that can be called multiple * times. The registration of the callback returns either a canceler or * synchronously returns a stream. The optionality of the error type `E` can * be used to signal the end of the stream, by setting it to `None`. * * @since 1.0.0 * @category constructors */ export declare const asyncInterrupt: (register: (emit: Emit.Emit) => Either.Either, Stream>, outputBuffer?: number) => Stream; /** * Creates a stream from an asynchronous callback that can be called multiple * times. The registration of the callback can possibly return the stream * synchronously. The optionality of the error type `E` can be used to signal * the end of the stream, by setting it to `None`. * * @since 1.0.0 * @category constructors */ export declare const asyncOption: (register: (emit: Emit.Emit) => Option.Option>, outputBuffer?: number) => Stream; /** * 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 1.0.0 * @category constructors */ export declare const asyncScoped: (register: (emit: Emit.Emit) => Effect.Effect, outputBuffer?: number) => Stream, E, A>; /** * 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 1.0.0 * @category sequencing */ export declare const branchAfter: { (n: number, f: (input: Chunk.Chunk) => Stream): (self: Stream) => Stream; (self: Stream, n: number, f: (input: Chunk.Chunk) => Stream): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const broadcast: { (n: N, maximumLag: number): (self: Stream) => Effect.Effect, N>>; (self: Stream, n: N, maximumLag: number): Effect.Effect, N>>; }; /** * 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 1.0.0 * @category utils */ export declare const broadcastDynamic: { (maximumLag: number): (self: Stream) => Effect.Effect>; (self: Stream, maximumLag: number): Effect.Effect>; }; /** * 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 1.0.0 * @category utils */ export declare const broadcastedQueues: { (n: N, maximumLag: number): (self: Stream) => Effect.Effect>, N>>; (self: Stream, n: N, maximumLag: number): Effect.Effect>, N>>; }; /** * 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 1.0.0 * @category utils */ export declare const broadcastedQueuesDynamic: { (maximumLag: number): (self: Stream) => Effect.Effect>>>; (self: Stream, maximumLag: number): Effect.Effect>>>; }; /** * 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 1.0.0 * @category utils */ export declare const buffer: { (options: { readonly capacity: "unbounded"; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend"; }): (self: Stream) => Stream; (self: Stream, options: { readonly capacity: "unbounded"; } | { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend"; }): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const bufferChunks: { (options: { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend"; }): (self: Stream) => Stream; (self: Stream, options: { readonly capacity: number; readonly strategy?: "dropping" | "sliding" | "suspend"; }): Stream; }; /** * Switches over to the stream produced by the provided function in case this * one fails with a typed error. * * @since 1.0.0 * @category error handling */ export declare const catchAll: { (f: (error: E) => Stream): (self: Stream) => Stream; (self: Stream, f: (error: E) => Stream): Stream; }; /** * 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 1.0.0 * @category error handling */ export declare const catchAllCause: { (f: (cause: Cause.Cause) => Stream): (self: Stream) => Stream; (self: Stream, f: (cause: Cause.Cause) => Stream): Stream; }; /** * Switches over to the stream produced by the provided function in case this * one fails with some typed error. * * @since 1.0.0 * @category error handling */ export declare const catchSome: { (pf: (error: E) => Option.Option>): (self: Stream) => Stream; (self: Stream, pf: (error: E) => Option.Option>): Stream; }; /** * Switches over to the stream produced by the provided function in case this * one fails with an error matching the given `_tag`. * * @since 1.0.0 * @category error handling */ export declare const catchTag: { (k: K, f: (e: Extract) => Stream): (self: Stream) => Stream, A1 | A>; (self: Stream, k: K, f: (e: Extract) => Stream): Stream, A | A1>; }; /** * 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 1.0.0 * @category error handling */ export declare const catchTags: { ) => Stream) | undefined; }>(cases: Cases): (self: Stream) => Stream) => Stream.Variance ? R : never; }[keyof Cases], Exclude | { [K in keyof Cases]: Cases[K] extends (...args: Array) => Stream.Variance ? E : never; }[keyof Cases], A | { [K in keyof Cases]: Cases[K] extends (...args: Array) => Stream.Variance ? A : never; }[keyof Cases]>; ) => Stream) | undefined; }>(self: Stream, cases: Cases): Stream) => Stream.Variance ? R : never; }[keyof Cases], Exclude | { [K in keyof Cases]: Cases[K] extends (...args: Array) => Stream.Variance ? E : never; }[keyof Cases], A | { [K in keyof Cases]: Cases[K] extends (...args: Array) => Stream.Variance ? A : 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 1.0.0 * @category error handling */ export declare const catchSomeCause: { (pf: (cause: Cause.Cause) => Option.Option>): (self: Stream) => Stream; (self: Stream, pf: (cause: Cause.Cause) => Option.Option>): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const changes: (self: Stream) => Stream; /** * 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 1.0.0 * @category utils */ export declare const changesWith: { (f: (x: A, y: A) => boolean): (self: Stream) => Stream; (self: Stream, f: (x: A, y: A) => boolean): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const changesWithEffect: { (f: (x: A, y: A) => Effect.Effect): (self: Stream) => Stream; (self: Stream, f: (x: A, y: A) => Effect.Effect): Stream; }; /** * Exposes the underlying chunks of the stream as a stream of chunks of * elements. * * @since 1.0.0 * @category utils */ export declare const chunks: (self: Stream) => Stream>; /** * Performs the specified stream transformation with the chunk structure of * the stream exposed. * * @since 1.0.0 * @category utils */ export declare const chunksWith: (f: (stream: Stream>) => Stream>) => (self: Stream) => Stream; /** * 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 1.0.0 * @category utils */ export declare const combine: { (that: Stream, s: S, f: (s: S, pullLeft: Effect.Effect, A>, pullRight: Effect.Effect, A2>) => Effect.Effect, readonly [A3, S]>>): (self: Stream) => Stream; (self: Stream, that: Stream, s: S, f: (s: S, pullLeft: Effect.Effect, A>, pullRight: Effect.Effect, A2>) => Effect.Effect, readonly [A3, S]>>): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const combineChunks: { (that: Stream, s: S, f: (s: S, pullLeft: Effect.Effect, Chunk.Chunk>, pullRight: Effect.Effect, Chunk.Chunk>) => Effect.Effect, readonly [Chunk.Chunk, S]>>): (self: Stream) => Stream; (self: Stream, that: Stream, s: S, f: (s: S, pullLeft: Effect.Effect, Chunk.Chunk>, pullRight: Effect.Effect, Chunk.Chunk>) => Effect.Effect, readonly [Chunk.Chunk, S]>>): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const concat: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * Concatenates all of the streams in the chunk to one stream. * * @since 1.0.0 * @category constructors */ export declare const concatAll: (streams: Chunk.Chunk>) => Stream; /** * 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 1.0.0 * @category utils */ export declare const cross: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const crossLeft: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const crossRight: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const crossWith: { (that: Stream, f: (a: A, b: B) => C): (self: Stream) => Stream; (self: Stream, that: Stream, f: (a: A, b: B) => C): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const debounce: { (duration: Duration.DurationInput): (self: Stream) => Stream; (self: Stream, duration: Duration.DurationInput): Stream; }; /** * The stream that dies with the specified defect. * * @since 1.0.0 * @category constructors */ export declare const die: (defect: unknown) => Stream; /** * The stream that dies with the specified lazily evaluated defect. * * @since 1.0.0 * @category constructors */ export declare const dieSync: (evaluate: LazyArg) => Stream; /** * The stream that dies with an exception described by `message`. * * @since 1.0.0 * @category constructors */ export declare const dieMessage: (message: string) => Stream; /** * 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 1.0.0 * @category utils */ export declare const distributedWith: { (options: { readonly size: N; readonly maximumLag: number; readonly decide: (a: A) => Effect.Effect>; }): (self: Stream) => Effect.Effect, A>>, N>>; (self: Stream, options: { readonly size: N; readonly maximumLag: number; readonly decide: (a: A) => Effect.Effect>; }): Effect.Effect, A>>, N>>; }; /** * 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 1.0.0 * @category utils */ export declare const distributedWithDynamic: { (options: { readonly maximumLag: number; readonly decide: (a: A) => Effect.Effect>; }): (self: Stream) => Effect.Effect, A>>]>>; (self: Stream, options: { readonly maximumLag: number; readonly decide: (a: A) => Effect.Effect>; }): Effect.Effect, A>>]>>; }; /** * Converts this stream to a stream that executes its effects but emits no * elements. Useful for sequencing effects using streams: * * @since 1.0.0 * @category utils */ export declare const drain: (self: Stream) => Stream; /** * 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 1.0.0 * @category utils */ export declare const drainFork: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * Drops the specified number of elements from this stream. * * @since 1.0.0 * @category utils */ export declare const drop: { (n: number): (self: Stream) => Stream; (self: Stream, n: number): Stream; }; /** * Drops the last specified number of elements from this stream. * * @note This combinator keeps `n` elements in memory. Be careful with big * numbers. * @since 1.0.0 * @category utils */ export declare const dropRight: { (n: number): (self: Stream) => Stream; (self: Stream, n: number): Stream; }; /** * Drops all elements of the stream until the specified predicate evaluates to * `true`. * * @since 1.0.0 * @category utils */ export declare const dropUntil: { (predicate: Predicate): (self: Stream) => Stream; (self: Stream, predicate: Predicate): Stream; }; /** * Drops all elements of the stream until the specified effectful predicate * evaluates to `true`. * * @since 1.0.0 * @category utils */ export declare const dropUntilEffect: { (predicate: (a: X) => Effect.Effect): (self: Stream) => Stream; (self: Stream, predicate: (a: X) => Effect.Effect): Stream; }; /** * Drops all elements of the stream for as long as the specified predicate * evaluates to `true`. * * @since 1.0.0 * @category utils */ export declare const dropWhile: { (predicate: Predicate): (self: Stream) => Stream; (self: Stream, predicate: Predicate): Stream; }; /** * Drops all elements of the stream for as long as the specified predicate * produces an effect that evalutates to `true` * * @since 1.0.0 * @category utils */ export declare const dropWhileEffect: { (predicate: (a: X) => Effect.Effect): (self: Stream) => Stream; (self: Stream, predicate: (a: X) => Effect.Effect): Stream; }; /** * 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 1.0.0 * @category utils */ export declare const either: (self: Stream) => Stream>; /** * The empty stream. * * @since 1.0.0 * @category constructors */ export declare const empty: Stream; /** * Executes the provided finalizer after this stream's finalizers run. * * @since 1.0.0 * @category utils */ export declare const ensuring: { (finalizer: Effect.Effect): (self: Stream) => Stream; (self: Stream, finalizer: Effect.Effect): Stream; }; /** * Executes the provided finalizer after this stream's finalizers run. * * @since 1.0.0 * @category utils */ export declare const ensuringWith: { (finalizer: (exit: Exit.Exit) => Effect.Effect): (self: Stream) => Stream; (self: Stream, finalizer: (exit: Exit.Exit) => Effect.Effect): Stream; }; /** * Accesses the whole context of the stream. * * @since 1.0.0 * @category context */ export declare const context: () => Stream>; /** * Accesses the context of the stream. * * @since 1.0.0 * @category context */ export declare const contextWith: (f: (env: Context.Context) => A) => Stream; /** * Accesses the context of the stream in the context of an effect. * * @since 1.0.0 * @category context */ export declare const contextWithEffect: (f: (env: Context.Context) => Effect.Effect) => Stream; /** * Accesses the context of the stream in the context of a stream. * * @since 1.0.0 * @category context */ export declare const contextWithStream: (f: (env: Context.Context) => Stream) => Stream; /** * Creates a stream that executes the specified effect but emits no elements. * * @since 1.0.0 * @category constructors */ export declare const execute: (effect: Effect.Effect) => Stream; /** * Terminates with the specified error. * * @since 1.0.0 * @category constructors */ export declare const fail: (error: E) => Stream; /** * Terminates with the specified lazily evaluated error. * * @since 1.0.0 * @category constructors */ export declare const failSync: (evaluate: LazyArg) => Stream; /** * The stream that always fails with the specified `Cause`. * * @since 1.0.0 * @category constructors */ export declare const failCause: (cause: Cause.Cause) => Stream; /** * The stream that always fails with the specified lazily evaluated `Cause`. * * @since 1.0.0 * @category constructors */ export declare const failCauseSync: (evaluate: LazyArg>) => Stream; /** * Filters the elements emitted by this stream using the provided function. * * @since 1.0.0 * @category filtering */ export declare const filter: { (refinement: Refinement): (self: Stream) => Stream; (predicate: Predicate): (self: Stream) => Stream; (self: Stream, refinement: Refinement): Stream; (self: Stream, predicate: Predicate): Stream; }; /** * Effectfully filters the elements emitted by this stream. * * @since 1.0.0 * @category filtering */ export declare const filterEffect: { (f: (a: X) => Effect.Effect): (self: Stream) => Stream; (self: Stream, f: (a: X) => Effect.Effect): Stream; }; /** * Performs a filter and map in a single step. * * @since 1.0.0 * @category utils */ export declare const filterMap: { (pf: (a: A) => Option.Option): (self: Stream) => Stream; (self: Stream, pf: (a: A) => Option.Option): Stream; }; /** * Performs an effectful filter and map in a single step. * * @since 1.0.0 * @category utils */ export declare const filterMapEffect: { (pf: (a: A) => Option.Option>): (self: Stream) => Stream; (self: Stream, pf: (a: A) => Option.Option>): Stream; }; /** * Transforms all elements of the stream for as long as the specified partial * function is defined. * * @since 1.0.0 * @category utils */ export declare const filterMapWhile: { (pf: (a: A) => Option.Option): (self: Stream) => Stream; (self: Stream, pf: (a: A) => Option.Option): Stream; }; /** * Effectfully transforms all elements of the stream for as long as the * specified partial function is defined. * * @since 1.0.0 * @category utils */ export declare const filterMapWhileEffect: { (pf: (a: A) => Option.Option>): (self: Stream) => Stream; (self: Stream, pf: (a: A) => Option.Option>): Stream; }; /** * Creates a one-element stream that never fails and executes the finalizer * when it ends. * * @since 1.0.0 * @category constructors */ export declare const finalizer: (finalizer: Effect.Effect) => Stream; /** * Finds the first element emitted by this stream that satisfies the provided * predicate. * * @since 1.0.0 * @category elements */ export declare const find: { (refinement: Refinement): (self: Stream) => Stream; (predicate: Predicate): (self: Stream) => Stream; (self: Stream, refinement: Refinement): Stream; (self: Stream, predicate: Predicate): Stream; }; /** * Finds the first element emitted by this stream that satisfies the provided * effectful predicate. * * @since 1.0.0 * @category elements */ export declare const findEffect: { (predicate: (a: X) => Effect.Effect): (self: Stream) => Stream; (self: Stream, predicate: (a: X) => Effect.Effect): Stream; }; /** * 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 1.0.0 * @category sequencing */ export declare const flatMap: { (f: (a: A) => Stream, options?: { readonly concurrency?: number | "unbounded"; readonly bufferSize?: number; readonly switch?: boolean; }): (self: Stream) => Stream; (self: Stream, f: (a: A) => Stream, options?: { readonly concurrency?: number | "unbounded"; readonly bufferSize?: number; readonly switch?: boolean; }): Stream; }; /** * Flattens this stream-of-streams into a stream made of the concatenation in * strict order of all the streams. * * @since 1.0.0 * @category sequencing */ export declare const flatten: { (options?: { readonly concurrency?: number | "unbounded"; readonly bufferSize?: number; }): (self: Stream>) => Stream; (self: Stream>, options?: { readonly concurrency?: number | "unbounded"; readonly bufferSize?: number; }): Stream; }; /** * Submerges the chunks carried by this stream into the stream's structure, * while still preserving them. * * @since 1.0.0 * @category sequencing */ export declare const flattenChunks: (self: Stream>) => Stream; /** * Flattens `Effect` values into the stream's structure, preserving all * information about the effect. * * @since 1.0.0 * @category sequencing */ export declare const flattenEffect: { (options?: { readonly concurrency?: number | "unbounded"; readonly unordered?: boolean; }): (self: Stream>) => Stream; (self: Stream>, options?: { readonly concurrency?: number | "unbounded"; readonly unordered?: boolean; }): Stream; }; /** * 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 1.0.0 * @category sequencing */ export declare const flattenExitOption: (self: Stream, A>>) => Stream; /** * Submerges the iterables carried by this stream into the stream's structure, * while still preserving them. * * @since 1.0.0 * @category sequencing */ export declare const flattenIterables: (self: Stream>) => Stream; /** * Unwraps `Exit` values and flatten chunks that also signify end-of-stream * by failing with `None`. * * @since 1.0.0 * @category sequencing */ export declare const flattenTake: (self: Stream>) => Stream; /** * Repeats this stream forever. * * @since 1.0.0 * @category utils */ export declare const forever: (self: Stream) => Stream; /** * Creates a stream from an `AsyncIterable`. * * @since 1.0.0 * @category constructors */ export declare const fromAsyncIterable: (iterable: AsyncIterable, onError: (e: unknown) => E) => Stream; /** * Creates a stream from a `Channel`. * * @since 1.0.0 * @category constructors */ export declare const fromChannel: (channel: Channel.Channel, unknown>) => Stream; /** * Creates a channel from a `Stream`. * * @since 1.0.0 * @category constructors */ export declare const toChannel: (stream: Stream) => Channel.Channel, unknown>; /** * Creates a stream from a `Chunk` of values. * * @since 1.0.0 * @category constructors */ export declare const fromChunk: (chunk: Chunk.Chunk) => Stream; /** * Creates a stream from a subscription to a `Hub`. * * @param shutdown If `true`, the hub will be shutdown after the stream is evaluated (defaults to `false`) * @since 1.0.0 * @category constructors */ export declare const fromChunkHub: { (hub: Hub.Hub>, options: { readonly scoped: true; readonly shutdown?: boolean; }): Effect.Effect>; (hub: Hub.Hub>, options?: { readonly scoped?: false; readonly shutdown?: boolean; }): Stream; }; /** * 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 1.0.0 * @category constructors */ export declare const fromChunkQueue: (queue: Queue.Dequeue>, options?: { readonly shutdown?: boolean; }) => Stream; /** * Creates a stream from an arbitrary number of chunks. * * @since 1.0.0 * @category constructors */ export declare const fromChunks: (...chunks: Array>) => Stream; /** * Either emits the success value of this effect or terminates the stream * with the failure value of this effect. * * @since 1.0.0 * @category constructors */ export declare const fromEffect: (effect: Effect.Effect) => Stream; /** * Creates a stream from an effect producing a value of type `A` or an empty * `Stream`. * * @since 1.0.0 * @category constructors */ export declare const fromEffectOption: (effect: Effect.Effect, A>) => Stream; /** * Creates a stream from a subscription to a `Hub`. * * @param shutdown If `true`, the hub will be shutdown after the stream is evaluated (defaults to `false`) * @since 1.0.0 * @category constructors */ export declare const fromHub: { (hub: Hub.Hub, options: { readonly scoped: true; readonly maxChunkSize?: number; readonly shutdown?: boolean; }): Effect.Effect>; (hub: Hub.Hub, options?: { readonly scoped?: false; readonly maxChunkSize?: number; readonly shutdown?: boolean; }): Stream; }; /** * Creates a stream from an `Iterable` collection of values. * * @since 1.0.0 * @category constructors */ export declare const fromIterable: (iterable: Iterable) => Stream; /** * Creates a stream from an effect producing a value of type `Iterable`. * * @since 1.0.0 * @category constructors */ export declare const fromIterableEffect: (effect: Effect.Effect>) => Stream; /** * Creates a stream from an iterator * * @since 1.0.0 * @category constructors */ export declare const fromIteratorSucceed: (iterator: IterableIterator, maxChunkSize?: number) => Stream; /** * Creates a stream from an effect that pulls elements from another stream. * * See `Stream.toPull` for reference. * * @since 1.0.0 * @category constructors */ export declare const fromPull: (effect: Effect.Effect, Chunk.Chunk>>) => Stream | R2, E, A>; /** * 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 1.0.0 * @category constructors */ export declare const fromQueue: (queue: Queue.Dequeue, options?: { readonly maxChunkSize?: number; readonly shutdown?: boolean; }) => Stream; /** * Creates a stream from a `ReadableStream`. * * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream. * * @since 1.0.0 * @category constructors */ export declare const fromReadableStream: (evaluate: LazyArg>, onError: (error: unknown) => E) => Stream; /** * 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 1.0.0 * @category constructors */ export declare const fromReadableStreamByob: (evaluate: LazyArg>, onError: (error: unknown) => E, allocSize?: number) => Stream; /** * 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 1.0.0 * @category constructors */ export declare const fromSchedule: (schedule: Schedule.Schedule) => Stream; /** * Creates a pipeline that groups on adjacent keys, calculated by the * specified function. * * @since 1.0.0 * @category grouping */ export declare const groupAdjacentBy: { (f: (a: A) => K): (self: Stream) => Stream]>; (self: Stream, f: (a: A) => K): Stream]>; }; /** * More powerful version of `Stream.groupByKey`. * * @since 1.0.0 * @category grouping */ export declare const groupBy: { (f: (a: A) => Effect.Effect, options?: { readonly bufferSize?: number; }): (self: Stream) => GroupBy.GroupBy; (self: Stream, f: (a: A) => Effect.Effect, options?: { readonly bufferSize?: number; }): GroupBy.GroupBy; }; /** * Partition a stream using a function and process each stream individually. * This returns a data structure that can be used to further filter down which * groups shall be processed. * * After calling apply on the GroupBy object, the remaining groups will be * processed in parallel and the resulting streams merged in a * nondeterministic fashion. * * Up to `buffer` elements may be buffered in any group stream before the * producer is backpressured. Take care to consume from all streams in order * to prevent deadlocks. * * For example, to collect the first 2 words for every starting letter from a * stream of words: * * ```ts * import * as GroupBy from "@effect/stream/GroupBy" * import * as Stream from "@effect/stream/Stream" * import { pipe } from "@effect/data/Function" * * pipe( * Stream.fromIterable(["hello", "world", "hi", "holla"]), * Stream.groupByKey((word) => word[0]), * GroupBy.evaluate((key, stream) => * pipe( * stream, * Stream.take(2), * Stream.map((words) => [key, words] as const) * ) * ) * ) * ``` * * @since 1.0.0 * @category utils */ export declare const groupByKey: { (f: (a: A) => K, options?: { readonly bufferSize?: number; }): (self: Stream) => GroupBy.GroupBy; (self: Stream, f: (a: A) => K, options?: { readonly bufferSize?: number; }): GroupBy.GroupBy; }; /** * Partitions the stream with specified `chunkSize`. * * @since 1.0.0 * @category utils */ export declare const grouped: { (chunkSize: number): (self: Stream) => Stream>; (self: Stream, chunkSize: number): Stream>; }; /** * Partitions the stream with the specified `chunkSize` or until the specified * `duration` has passed, whichever is satisfied first. * * @since 1.0.0 * @category utils */ export declare const groupedWithin: { (chunkSize: number, duration: Duration.DurationInput): (self: Stream) => Stream>; (self: Stream, chunkSize: number, duration: Duration.DurationInput): Stream>; }; /** * Specialized version of haltWhen which halts the evaluation of this stream * after the given duration. * * An element in the process of being pulled will not be interrupted when the * given duration completes. See `interruptAfter` for this behavior. * * @since 1.0.0 * @category utils */ export declare const haltAfter: { (duration: Duration.DurationInput): (self: Stream) => Stream; (self: Stream, duration: Duration.DurationInput): Stream; }; /** * Halts the evaluation of this stream when the provided effect completes. The * given effect will be forked as part of the returned stream, and its success * will be discarded. * * An element in the process of being pulled will not be interrupted when the * effect completes. See `interruptWhen` for this behavior. * * If the effect completes with a failure, the stream will emit that failure. * * @since 1.0.0 * @category utils */ export declare const haltWhen: { (effect: Effect.Effect): (self: Stream) => Stream; (self: Stream, effect: Effect.Effect): Stream; }; /** * Halts the evaluation of this stream when the provided promise resolves. * * If the promise completes with a failure, the stream will emit that failure. * * @since 1.0.0 * @category utils */ export declare const haltWhenDeferred: { (deferred: Deferred.Deferred): (self: Stream) => Stream; (self: Stream, deferred: Deferred.Deferred): Stream; }; /** * The identity pipeline, which does not modify streams in any way. * * @since 1.0.0 * @category utils */ export declare const identity: () => Stream; /** * Interleaves this stream and the specified stream deterministically by * alternating pulling values from this stream and the specified stream. When * one stream is exhausted all remaining values in the other stream will be * pulled. * * @since 1.0.0 * @category utils */ export declare const interleave: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * Combines this stream and the specified stream deterministically using the * stream of boolean values `pull` to control which stream to pull from next. * A value of `true` indicates to pull from this stream and a value of `false` * indicates to pull from the specified stream. Only consumes as many elements * as requested by the `pull` stream. If either this stream or the specified * stream are exhausted further requests for values from that stream will be * ignored. * * @since 1.0.0 * @category utils */ export declare const interleaveWith: { (that: Stream, decider: Stream): (self: Stream) => Stream; (self: Stream, that: Stream, decider: Stream): Stream; }; /** * Intersperse stream with provided `element`. * * @since 1.0.0 * @category utils */ export declare const intersperse: { (element: A2): (self: Stream) => Stream; (self: Stream, element: A2): Stream; }; /** * Intersperse the specified element, also adding a prefix and a suffix. * * @since 1.0.0 * @category utils */ export declare const intersperseAffixes: { (options: { readonly start: A2; readonly middle: A3; readonly end: A4; }): (self: Stream) => Stream; (self: Stream, options: { readonly start: A2; readonly middle: A3; readonly end: A4; }): Stream; }; /** * Specialized version of `Stream.interruptWhen` which interrupts the * evaluation of this stream after the given `Duration`. * * @since 1.0.0 * @category utils */ export declare const interruptAfter: { (duration: Duration.DurationInput): (self: Stream) => Stream; (self: Stream, duration: Duration.DurationInput): Stream; }; /** * Interrupts the evaluation of this stream when the provided effect * completes. The given effect will be forked as part of this stream, and its * success will be discarded. This combinator will also interrupt any * in-progress element being pulled from upstream. * * If the effect completes with a failure before the stream completes, the * returned stream will emit that failure. * * @since 1.0.0 * @category utils */ export declare const interruptWhen: { (effect: Effect.Effect): (self: Stream) => Stream; (self: Stream, effect: Effect.Effect): Stream; }; /** * Interrupts the evaluation of this stream when the provided promise * resolves. This combinator will also interrupt any in-progress element being * pulled from upstream. * * If the promise completes with a failure, the stream will emit that failure. * * @since 1.0.0 * @category utils */ export declare const interruptWhenDeferred: { (deferred: Deferred.Deferred): (self: Stream) => Stream; (self: Stream, deferred: Deferred.Deferred): Stream; }; /** * The infinite stream of iterative function application: a, f(a), f(f(a)), * f(f(f(a))), ... * * @since 1.0.0 * @category constructors */ export declare const iterate: (value: A, next: (value: A) => A) => Stream; /** * Creates a stream from an sequence of values. * * @since 1.0.0 * @category constructors */ export declare const make: >(...as: As) => Stream; /** * Transforms the elements of this stream using the supplied function. * * @since 1.0.0 * @category mapping */ export declare const map: { (f: (a: A) => B): (self: Stream) => Stream; (self: Stream, f: (a: A) => B): Stream; }; /** * Statefully maps over the elements of this stream to produce new elements. * * @since 1.0.0 * @category mapping */ export declare const mapAccum: { (s: S, f: (s: S, a: A) => readonly [S, A2]): (self: Stream) => Stream; (self: Stream, s: S, f: (s: S, a: A) => readonly [S, A2]): Stream; }; /** * Statefully and effectfully maps over the elements of this stream to produce * new elements. * * @since 1.0.0 * @category mapping */ export declare const mapAccumEffect: { (s: S, f: (s: S, a: A) => Effect.Effect): (self: Stream) => Stream; (self: Stream, s: S, f: (s: S, a: A) => Effect.Effect): Stream; }; /** * Returns a stream whose failure and success channels have been mapped by the * specified `onFailure` and `onSuccess` functions. * * @since 1.0.0 * @category utils */ export declare const mapBoth: { (options: { readonly onFailure: (e: E) => E2; readonly onSuccess: (a: A) => A2; }): (self: Stream) => Stream; (self: Stream, options: { readonly onFailure: (e: E) => E2; readonly onSuccess: (a: A) => A2; }): Stream; }; /** * Transforms the chunks emitted by this stream. * * @since 1.0.0 * @category mapping */ export declare const mapChunks: { (f: (chunk: Chunk.Chunk) => Chunk.Chunk): (self: Stream) => Stream; (self: Stream, f: (chunk: Chunk.Chunk) => Chunk.Chunk): Stream; }; /** * Effectfully transforms the chunks emitted by this stream. * * @since 1.0.0 * @category mapping */ export declare const mapChunksEffect: { (f: (chunk: Chunk.Chunk) => Effect.Effect>): (self: Stream) => Stream; (self: Stream, f: (chunk: Chunk.Chunk) => Effect.Effect>): Stream; }; /** * Maps each element to an iterable, and flattens the iterables into the * output of this stream. * * @since 1.0.0 * @category mapping */ export declare const mapConcat: { (f: (a: A) => Iterable): (self: Stream) => Stream; (self: Stream, f: (a: A) => Iterable): Stream; }; /** * Maps each element to a chunk, and flattens the chunks into the output of * this stream. * * @since 1.0.0 * @category mapping */ export declare const mapConcatChunk: { (f: (a: A) => Chunk.Chunk): (self: Stream) => Stream; (self: Stream, f: (a: A) => Chunk.Chunk): Stream; }; /** * Effectfully maps each element to a chunk, and flattens the chunks into the * output of this stream. * * @since 1.0.0 * @category mapping */ export declare const mapConcatChunkEffect: { (f: (a: A) => Effect.Effect>): (self: Stream) => Stream; (self: Stream, f: (a: A) => Effect.Effect>): Stream; }; /** * Effectfully maps each element to an iterable, and flattens the iterables * into the output of this stream. * * @since 1.0.0 * @category mapping */ export declare const mapConcatEffect: { (f: (a: A) => Effect.Effect>): (self: Stream) => Stream; (self: Stream, f: (a: A) => Effect.Effect>): Stream; }; /** * Maps over elements of the stream with the specified effectful function. * * @since 1.0.0 * @category mapping */ export declare const mapEffect: { (f: (a: A) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded"; readonly unordered?: boolean; }): (self: Stream) => Stream; (f: (a: A) => Effect.Effect, options: { readonly key: (a: A) => K; readonly bufferSize?: number; }): (self: Stream) => Stream; (self: Stream, f: (a: A) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded"; readonly unordered?: boolean; }): Stream; (self: Stream, f: (a: A) => Effect.Effect, options: { readonly key: (a: A) => K; readonly bufferSize?: number; }): Stream; }; /** * Transforms the errors emitted by this stream using `f`. * * @since 1.0.0 * @category mapping */ export declare const mapError: { (f: (error: E) => E2): (self: Stream) => Stream; (self: Stream, f: (error: E) => E2): Stream; }; /** * Transforms the full causes of failures emitted by this stream. * * @since 1.0.0 * @category mapping */ export declare const mapErrorCause: { (f: (cause: Cause.Cause) => Cause.Cause): (self: Stream) => Stream; (self: Stream, f: (cause: Cause.Cause) => Cause.Cause): Stream; }; /** * Merges this stream and the specified stream together. * * New produced stream will terminate when both specified stream terminate if * no termination strategy is specified. * * @since 1.0.0 * @category utils */ export declare const merge: { (that: Stream, options?: { readonly haltStrategy?: HaltStrategy.HaltStrategyInput; }): (self: Stream) => Stream; (self: Stream, that: Stream, options?: { readonly haltStrategy?: HaltStrategy.HaltStrategyInput; }): Stream; }; /** * Merges a variable list of streams in a non-deterministic fashion. Up to `n` * streams may be consumed in parallel and up to `outputBuffer` chunks may be * buffered by this operator. * * @since 1.0.0 * @category utils */ export declare const mergeAll: { (options: { readonly concurrency: number | "unbounded"; readonly bufferSize?: number; }): (streams: Iterable>) => Stream; (streams: Iterable>, options: { readonly concurrency: number | "unbounded"; readonly bufferSize?: number; }): Stream; }; /** * Merges this stream and the specified stream together to a common element * type with the specified mapping functions. * * New produced stream will terminate when both specified stream terminate if * no termination strategy is specified. * * @since 1.0.0 * @category utils */ export declare const mergeWith: { (other: Stream, options: { readonly onSelf: (a: A) => A3; readonly onOther: (a2: A2) => A4; readonly haltStrategy?: HaltStrategy.HaltStrategyInput; }): (self: Stream) => Stream; (self: Stream, other: Stream, options: { readonly onSelf: (a: A) => A3; readonly onOther: (a2: A2) => A4; readonly haltStrategy?: HaltStrategy.HaltStrategyInput; }): Stream; }; /** * Merges this stream and the specified stream together to produce a stream of * eithers. * * @since 1.0.0 * @category utils */ export declare const mergeEither: { (that: Stream): (self: Stream) => Stream>; (self: Stream, that: Stream): Stream>; }; /** * Merges this stream and the specified stream together, discarding the values * from the right stream. * * @since 1.0.0 * @category utils */ export declare const mergeLeft: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * Merges this stream and the specified stream together, discarding the values * from the left stream. * * @since 1.0.0 * @category utils */ export declare const mergeRight: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * Returns a combined string resulting from concatenating each of the values * from the stream. * * @since 1.0.0 * @category utils */ export declare const mkString: (self: Stream) => Effect.Effect; /** * The stream that never produces any value or fails with any error. * * @since 1.0.0 * @category constructors */ export declare const never: Stream; /** * Runs the specified effect if this stream fails, providing the error to the * effect if it exists. * * Note: Unlike `Effect.onError` there is no guarantee that the provided * effect will not be interrupted. * * @since 1.0.0 * @category utils */ export declare const onError: { (cleanup: (cause: Cause.Cause) => Effect.Effect): (self: Stream) => Stream; (self: Stream, cleanup: (cause: Cause.Cause) => Effect.Effect): Stream; }; /** * Runs the specified effect if this stream ends. * * @since 1.0.0 * @category utils */ export declare const onDone: { (cleanup: () => Effect.Effect): (self: Stream) => Stream; (self: Stream, cleanup: () => Effect.Effect): Stream; }; /** * Translates any failure into a stream termination, making the stream * infallible and all failures unchecked. * * @since 1.0.0 * @category error handling */ export declare const orDie: (self: Stream) => Stream; /** * Keeps none of the errors, and terminates the stream with them, using the * specified function to convert the `E` into a defect. * * @since 1.0.0 * @category error handling */ export declare const orDieWith: { (f: (e: E) => unknown): (self: Stream) => Stream; (self: Stream, f: (e: E) => unknown): Stream; }; /** * Switches to the provided stream in case this one fails with a typed error. * * See also `Stream.catchAll`. * * @since 1.0.0 * @category error handling */ export declare const orElse: { (that: LazyArg>): (self: Stream) => Stream; (self: Stream, that: LazyArg>): Stream; }; /** * Switches to the provided stream in case this one fails with a typed error. * * See also `Stream.catchAll`. * * @since 1.0.0 * @category error handling */ export declare const orElseEither: { (that: LazyArg>): (self: Stream) => Stream>; (self: Stream, that: LazyArg>): Stream>; }; /** * Fails with given error in case this one fails with a typed error. * * See also `Stream.catchAll`. * * @since 1.0.0 * @category error handling */ export declare const orElseFail: { (error: LazyArg): (self: Stream) => Stream; (self: Stream, error: LazyArg): Stream; }; /** * Produces the specified element if this stream is empty. * * @since 1.0.0 * @category error handling */ export declare const orElseIfEmpty: { (element: LazyArg): (self: Stream) => Stream; (self: Stream, element: LazyArg): Stream; }; /** * Produces the specified chunk if this stream is empty. * * @since 1.0.0 * @category error handling */ export declare const orElseIfEmptyChunk: { (chunk: LazyArg>): (self: Stream) => Stream; (self: Stream, chunk: LazyArg>): Stream; }; /** * Switches to the provided stream in case this one is empty. * * @since 1.0.0 * @category error handling */ export declare const orElseIfEmptyStream: { (stream: LazyArg>): (self: Stream) => Stream; (self: Stream, stream: LazyArg>): Stream; }; /** * Succeeds with the specified value if this one fails with a typed error. * * @since 1.0.0 * @category error handling */ export declare const orElseSucceed: { (value: LazyArg): (self: Stream) => Stream; (self: Stream, value: LazyArg): Stream; }; /** * Like `Stream.unfold`, but allows the emission of values to end one step further * than the unfolding of the state. This is useful for embedding paginated * APIs, hence the name. * * @since 1.0.0 * @category constructors */ export declare const paginate: (s: S, f: (s: S) => readonly [A, Option.Option]) => Stream; /** * Like `Stream.unfoldChunk`, but allows the emission of values to end one step * further than the unfolding of the state. This is useful for embedding * paginated APIs, hence the name. * * @since 1.0.0 * @category constructors */ export declare const paginateChunk: (s: S, f: (s: S) => readonly [Chunk.Chunk, Option.Option]) => Stream; /** * Like `Stream.unfoldChunkEffect`, but allows the emission of values to end one step * further than the unfolding of the state. This is useful for embedding * paginated APIs, hence the name. * * @since 1.0.0 * @category constructors */ export declare const paginateChunkEffect: (s: S, f: (s: S) => Effect.Effect, Option.Option]>) => Stream; /** * Like `Stream.unfoldEffect` but allows the emission of values to end one step * further than the unfolding of the state. This is useful for embedding * paginated APIs, hence the name. * * @since 1.0.0 * @category constructors */ export declare const paginateEffect: (s: S, f: (s: S) => Effect.Effect]>) => Stream; /** * Partition a stream using a predicate. The first stream will contain all * element evaluated to true and the second one will contain all element * evaluated to false. The faster stream may advance by up to buffer elements * further than the slower one. * * @since 1.0.0 * @category utils */ export declare const partition: { (predicate: Predicate, options?: { bufferSize?: number; }): (self: Stream) => Effect.Effect, Stream]>; (self: Stream, predicate: Predicate, options?: { bufferSize?: number; }): Effect.Effect, Stream]>; }; /** * Split a stream by an effectful predicate. The faster stream may advance by * up to buffer elements further than the slower one. * * @since 1.0.0 * @category utils */ export declare const partitionEither: { (predicate: (a: A) => Effect.Effect>, options?: { readonly bufferSize?: number; }): (self: Stream) => Effect.Effect, Stream]>; (self: Stream, predicate: (a: A) => Effect.Effect>, options?: { readonly bufferSize?: number; }): Effect.Effect, Stream]>; }; /** * Peels off enough material from the stream to construct a `Z` using the * provided `Sink` and then returns both the `Z` and the rest of the * `Stream` in a scope. Like all scoped values, the provided stream is * valid only within the scope. * * @since 1.0.0 * @category utils */ export declare const peel: { (sink: Sink.Sink): (self: Stream) => Effect.Effect]>; (self: Stream, sink: Sink.Sink): Effect.Effect]>; }; /** * Pipes all of the values from this stream through the provided sink. * * See also `Stream.transduce`. * * @since 1.0.0 * @category utils */ export declare const pipeThrough: { (sink: Sink.Sink): (self: Stream) => Stream; (self: Stream, sink: Sink.Sink): Stream; }; /** * Pipes all the values from this stream through the provided channel. * * @since 1.0.0 * @category utils */ export declare const pipeThroughChannel: { (channel: Channel.Channel, unknown, E2, Chunk.Chunk, unknown>): (self: Stream) => Stream; (self: Stream, channel: Channel.Channel, unknown, E2, Chunk.Chunk, unknown>): Stream; }; /** * Pipes all values from this stream through the provided channel, passing * through any error emitted by this stream unchanged. * * @since 1.0.0 * @category utils */ export declare const pipeThroughChannelOrFail: { (chan: Channel.Channel, unknown, E2, Chunk.Chunk, unknown>): (self: Stream) => Stream; (self: Stream, chan: Channel.Channel, unknown, E2, Chunk.Chunk, unknown>): Stream; }; /** * Emits the provided chunk before emitting any other value. * * @since 1.0.0 * @category utils */ export declare const prepend: { (values: Chunk.Chunk): (self: Stream) => Stream; (self: Stream, values: Chunk.Chunk): Stream; }; /** * Provides the stream with its required context, which eliminates its * dependency on `R`. * * @since 1.0.0 * @category context */ export declare const provideContext: { (context: Context.Context): (self: Stream) => Stream; (self: Stream, context: Context.Context): Stream; }; /** * Provides a `Layer` to the stream, which translates it to another level. * * @since 1.0.0 * @category context */ export declare const provideLayer: { (layer: Layer.Layer): (self: Stream) => Stream; (self: Stream, layer: Layer.Layer): Stream; }; /** * Provides the stream with the single service it requires. If the stream * requires more than one service use `Stream.provideContext` instead. * * @since 1.0.0 * @category context */ export declare const provideService: { >(tag: T, resource: Context.Tag.Service): (self: Stream) => Stream>, E, A>; >(self: Stream, tag: T, resource: Context.Tag.Service): Stream>, E, A>; }; /** * Provides the stream with the single service it requires. If the stream * requires more than one service use `Stream.provideContext` instead. * * @since 1.0.0 * @category context */ export declare const provideServiceEffect: { , R2, E2>(tag: T, effect: Effect.Effect>): (self: Stream) => Stream>, E2 | E, A>; , R2, E2>(self: Stream, tag: T, effect: Effect.Effect>): Stream>, E | E2, A>; }; /** * Provides the stream with the single service it requires. If the stream * requires more than one service use `Stream.provideContext` instead. * * @since 1.0.0 * @category context */ export declare const provideServiceStream: { , R2, E2>(tag: T, stream: Stream>): (self: Stream) => Stream>, E2 | E, A>; , R2, E2>(self: Stream, tag: T, stream: Stream>): Stream>, E | E2, A>; }; /** * Transforms the context being provided to the stream with the specified * function. * * @since 1.0.0 * @category context */ export declare const mapInputContext: { (f: (env: Context.Context) => Context.Context): (self: Stream) => Stream; (self: Stream, f: (env: Context.Context) => Context.Context): Stream; }; /** * Splits the context into two parts, providing one part using the * specified layer and leaving the remainder `R0`. * * @since 1.0.0 * @category context */ export declare const provideSomeLayer: { (layer: Layer.Layer): (self: Stream) => Stream, E2 | E, A>; (self: Stream, layer: Layer.Layer): Stream, E | E2, A>; }; /** * Constructs a stream from a range of integers, including both endpoints. * * @since 1.0.0 * @category constructors */ export declare const range: (min: number, max: number, chunkSize?: number) => Stream; /** * Re-chunks the elements of the stream into chunks of `n` elements each. The * last chunk might contain less than `n` elements. * * @since 1.0.0 * @category utils */ export declare const rechunk: { (n: number): (self: Stream) => Stream; (self: Stream, n: number): Stream; }; /** * Keeps some of the errors, and terminates the fiber with the rest * * @since 1.0.0 * @category error handling */ export declare const refineOrDie: { (pf: (error: E) => Option.Option): (self: Stream) => Stream; (self: Stream, pf: (error: E) => Option.Option): Stream; }; /** * Keeps some of the errors, and terminates the fiber with the rest, using the * specified function to convert the `E` into a defect. * * @since 1.0.0 * @category error handling */ export declare const refineOrDieWith: { (pf: (error: E) => Option.Option, f: (error: E) => unknown): (self: Stream) => Stream; (self: Stream, pf: (error: E) => Option.Option, f: (error: E) => unknown): Stream; }; /** * Repeats the entire stream using the specified schedule. The stream will * execute normally, and then repeat again according to the provided schedule. * * @since 1.0.0 * @category utils */ export declare const repeat: { (schedule: Schedule.Schedule): (self: Stream) => Stream; (self: Stream, schedule: Schedule.Schedule): Stream; }; /** * Creates a stream from an effect producing a value of type `A` which repeats * forever. * * @since 1.0.0 * @category constructors */ export declare const repeatEffect: (effect: Effect.Effect) => Stream; /** * Creates a stream from an effect producing chunks of `A` values which * repeats forever. * * @since 1.0.0 * @category constructors */ export declare const repeatEffectChunk: (effect: Effect.Effect>) => Stream; /** * Creates a stream from an effect producing chunks of `A` values until it * fails with `None`. * * @since 1.0.0 * @category constructors */ export declare const repeatEffectChunkOption: (effect: Effect.Effect, Chunk.Chunk>) => Stream; /** * Creates a stream from an effect producing values of type `A` until it fails * with `None`. * * @since 1.0.0 * @category constructors */ export declare const repeatEffectOption: (effect: Effect.Effect, A>) => Stream; /** * Creates a stream from an effect producing a value of type `A`, which is * repeated using the specified schedule. * * @since 1.0.0 * @category constructors */ export declare const repeatEffectWithSchedule: (effect: Effect.Effect, schedule: Schedule.Schedule) => Stream; /** * Repeats the entire stream using the specified schedule. The stream will * execute normally, and then repeat again according to the provided schedule. * The schedule output will be emitted at the end of each repetition. * * @since 1.0.0 * @category utils */ export declare const repeatEither: { (schedule: Schedule.Schedule): (self: Stream) => Stream>; (self: Stream, schedule: Schedule.Schedule): Stream>; }; /** * Repeats each element of the stream using the provided schedule. Repetitions * are done in addition to the first execution, which means using * `Schedule.recurs(1)` actually results in the original effect, plus an * additional recurrence, for a total of two repetitions of each value in the * stream. * * @since 1.0.0 * @category utils */ export declare const repeatElements: { (schedule: Schedule.Schedule): (self: Stream) => Stream; (self: Stream, schedule: Schedule.Schedule): Stream; }; /** * Repeats each element of the stream using the provided schedule. When the * schedule is finished, then the output of the schedule will be emitted into * the stream. Repetitions are done in addition to the first execution, which * means using `Schedule.recurs(1)` actually results in the original effect, * plus an additional recurrence, for a total of two repetitions of each value * in the stream. * * This function accepts two conversion functions, which allow the output of * this stream and the output of the provided schedule to be unified into a * single type. For example, `Either` or similar data type. * * @since 1.0.0 * @category utils */ export declare const repeatElementsWith: { (schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C; }): (self: Stream) => Stream; (self: Stream, schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C; }): Stream; }; /** * Repeats the provided value infinitely. * * @since 1.0.0 * @category constructors */ export declare const repeatValue: (value: A) => Stream; /** * Repeats the entire stream using the specified schedule. The stream will * execute normally, and then repeat again according to the provided schedule. * The schedule output will be emitted at the end of each repetition and can * be unified with the stream elements using the provided functions. * * @since 1.0.0 * @category utils */ export declare const repeatWith: { (schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C; }): (self: Stream) => Stream; (self: Stream, schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C; }): Stream; }; /** * When the stream fails, retry it according to the given schedule * * This retries the entire stream, so will re-execute all of the stream's * acquire operations. * * The schedule is reset as soon as the first element passes through the * stream again. * * @param schedule A `Schedule` receiving as input the errors of the stream. * @since 1.0.0 * @category utils */ export declare const retry: { (schedule: Schedule.Schedule): (self: Stream) => Stream; (self: Stream, schedule: Schedule.Schedule): Stream; }; /** * Runs the sink on the stream to produce either the sink's result or an error. * * @since 1.0.0 * @category destructors */ export declare const run: { (sink: Sink.Sink): (self: Stream) => Effect.Effect; (self: Stream, sink: Sink.Sink): Effect.Effect; }; /** * Runs the stream and collects all of its elements to a chunk. * * @since 1.0.0 * @category destructors */ export declare const runCollect: (self: Stream) => Effect.Effect>; /** * Runs the stream and emits the number of elements processed * * @since 1.0.0 * @category destructors */ export declare const runCount: (self: Stream) => Effect.Effect; /** * Runs the stream only for its effects. The emitted elements are discarded. * * @since 1.0.0 * @category destructors */ export declare const runDrain: (self: Stream) => Effect.Effect; /** * Executes a pure fold over the stream of values - reduces all elements in * the stream to a value of type `S`. * * @since 1.0.0 * @category destructors */ export declare const runFold: { (s: S, f: (s: S, a: A) => S): (self: Stream) => Effect.Effect; (self: Stream, s: S, f: (s: S, a: A) => S): Effect.Effect; }; /** * Executes an effectful fold over the stream of values. * * @since 1.0.0 * @category destructors */ export declare const runFoldEffect: { (s: S, f: (s: S, a: A) => Effect.Effect): (self: Stream) => Effect.Effect; (self: Stream, s: S, f: (s: S, a: A) => Effect.Effect): Effect.Effect; }; /** * Executes a pure fold over the stream of values. Returns a scoped value that * represents the scope of the stream. * * @since 1.0.0 * @category destructors */ export declare const runFoldScoped: { (s: S, f: (s: S, a: A) => S): (self: Stream) => Effect.Effect; (self: Stream, s: S, f: (s: S, a: A) => S): Effect.Effect; }; /** * Executes an effectful fold over the stream of values. Returns a scoped * value that represents the scope of the stream. * * @since 1.0.0 * @category destructors */ export declare const runFoldScopedEffect: { (s: S, f: (s: S, a: A) => Effect.Effect): (self: Stream) => Effect.Effect; (self: Stream, s: S, f: (s: S, a: A) => Effect.Effect): Effect.Effect; }; /** * Reduces the elements in the stream to a value of type `S`. Stops the fold * early when the condition is not fulfilled. Example: * * @since 1.0.0 * @category destructors */ export declare const runFoldWhile: { (s: S, cont: Predicate, f: (s: S, a: A) => S): (self: Stream) => Effect.Effect; (self: Stream, s: S, cont: Predicate, f: (s: S, a: A) => S): Effect.Effect; }; /** * Executes an effectful fold over the stream of values. Stops the fold early * when the condition is not fulfilled. * * @since 1.0.0 * @category destructors */ export declare const runFoldWhileEffect: { (s: S, cont: Predicate, f: (s: S, a: A) => Effect.Effect): (self: Stream) => Effect.Effect; (self: Stream, s: S, cont: Predicate, f: (s: S, a: A) => Effect.Effect): Effect.Effect; }; /** * Executes a pure fold over the stream of values. Returns a scoped value that * represents the scope of the stream. Stops the fold early when the condition * is not fulfilled. * * @since 1.0.0 * @category destructors */ export declare const runFoldWhileScoped: { (s: S, cont: Predicate, f: (s: S, a: A) => S): (self: Stream) => Effect.Effect; (self: Stream, s: S, cont: Predicate, f: (s: S, a: A) => S): Effect.Effect; }; /** * Executes an effectful fold over the stream of values. Returns a scoped * value that represents the scope of the stream. Stops the fold early when * the condition is not fulfilled. * * @since 1.0.0 * @category destructors */ export declare const runFoldWhileScopedEffect: { (s: S, cont: Predicate, f: (s: S, a: A) => Effect.Effect): (self: Stream) => Effect.Effect; (self: Stream, s: S, cont: Predicate, f: (s: S, a: A) => Effect.Effect): Effect.Effect; }; /** * Consumes all elements of the stream, passing them to the specified * callback. * * @since 1.0.0 * @category destructors */ export declare const runForEach: { (f: (a: A) => Effect.Effect): (self: Stream) => Effect.Effect; (self: Stream, f: (a: A) => Effect.Effect): Effect.Effect; }; /** * Consumes all elements of the stream, passing them to the specified * callback. * * @since 1.0.0 * @category destructors */ export declare const runForEachChunk: { (f: (a: Chunk.Chunk) => Effect.Effect): (self: Stream) => Effect.Effect; (self: Stream, f: (a: Chunk.Chunk) => Effect.Effect): Effect.Effect; }; /** * Like `Stream.runForEachChunk`, but returns a scoped effect so the * finalization order can be controlled. * * @since 1.0.0 * @category destructors */ export declare const runForEachChunkScoped: { (f: (a: Chunk.Chunk) => Effect.Effect): (self: Stream) => Effect.Effect; (self: Stream, f: (a: Chunk.Chunk) => Effect.Effect): Effect.Effect; }; /** * Like `Stream.forEach`, but returns a scoped effect so the finalization * order can be controlled. * * @since 1.0.0 * @category destructors */ export declare const runForEachScoped: { (f: (a: A) => Effect.Effect): (self: Stream) => Effect.Effect; (self: Stream, f: (a: A) => Effect.Effect): Effect.Effect; }; /** * Consumes elements of the stream, passing them to the specified callback, * and terminating consumption when the callback returns `false`. * * @since 1.0.0 * @category destructors */ export declare const runForEachWhile: { (f: (a: A) => Effect.Effect): (self: Stream) => Effect.Effect; (self: Stream, f: (a: A) => Effect.Effect): Effect.Effect; }; /** * Like `Stream.runForEachWhile`, but returns a scoped effect so the * finalization order can be controlled. * * @since 1.0.0 * @category destructors */ export declare const runForEachWhileScoped: { (f: (a: A) => Effect.Effect): (self: Stream) => Effect.Effect; (self: Stream, f: (a: A) => Effect.Effect): Effect.Effect; }; /** * Runs the stream to completion and yields the first value emitted by it, * discarding the rest of the elements. * * @since 1.0.0 * @category destructors */ export declare const runHead: (self: Stream) => Effect.Effect>; /** * Publishes elements of this stream to a hub. Stream failure and ending will * also be signalled. * * @since 1.0.0 * @category destructors */ export declare const runIntoHub: { (hub: Hub.Hub>): (self: Stream) => Effect.Effect; (self: Stream, hub: Hub.Hub>): Effect.Effect; }; /** * Like `Stream.runIntoHub`, but provides the result as a scoped effect to * allow for scope composition. * * @since 1.0.0 * @category destructors */ export declare const runIntoHubScoped: { (hub: Hub.Hub>): (self: Stream) => Effect.Effect; (self: Stream, hub: Hub.Hub>): Effect.Effect; }; /** * Enqueues elements of this stream into a queue. Stream failure and ending * will also be signalled. * * @since 1.0.0 * @category destructors */ export declare const runIntoQueue: { (queue: Queue.Enqueue>): (self: Stream) => Effect.Effect; (self: Stream, queue: Queue.Enqueue>): Effect.Effect; }; /** * Like `Stream.runIntoQueue`, but provides the result as a scoped [[ZIO]] * to allow for scope composition. * * @since 1.0.0 * @category destructors */ export declare const runIntoQueueElementsScoped: { (queue: Queue.Enqueue, A>>): (self: Stream) => Effect.Effect; (self: Stream, queue: Queue.Enqueue, A>>): Effect.Effect; }; /** * Like `Stream.runIntoQueue`, but provides the result as a scoped effect * to allow for scope composition. * * @since 1.0.0 * @category destructors */ export declare const runIntoQueueScoped: { (queue: Queue.Enqueue>): (self: Stream) => Effect.Effect; (self: Stream, queue: Queue.Enqueue>): Effect.Effect; }; /** * Runs the stream to completion and yields the last value emitted by it, * discarding the rest of the elements. * * @since 1.0.0 * @category destructors */ export declare const runLast: (self: Stream) => Effect.Effect>; /** * @since 1.0.0 * @category destructors */ export declare const runScoped: { (sink: Sink.Sink): (self: Stream) => Effect.Effect; (self: Stream, sink: Sink.Sink): Effect.Effect; }; /** * Runs the stream to a sink which sums elements, provided they are Numeric. * * @since 1.0.0 * @category destructors */ export declare const runSum: (self: Stream) => Effect.Effect; /** * Statefully maps over the elements of this stream to produce all * intermediate results of type `S` given an initial S. * * @since 1.0.0 * @category utils */ export declare const scan: { (s: S, f: (s: S, a: A) => S): (self: Stream) => Stream; (self: Stream, s: S, f: (s: S, a: A) => S): Stream; }; /** * Statefully and effectfully maps over the elements of this stream to produce * all intermediate results of type `S` given an initial S. * * @since 1.0.0 * @category utils */ export declare const scanEffect: { (s: S, f: (s: S, a: A) => Effect.Effect): (self: Stream) => Stream; (self: Stream, s: S, f: (s: S, a: A) => Effect.Effect): Stream; }; /** * Statefully maps over the elements of this stream to produce all * intermediate results. * * See also `Stream.scan`. * * @since 1.0.0 * @category utils */ export declare const scanReduce: { (f: (a2: A2 | A, a: A) => A2): (self: Stream) => Stream; (self: Stream, f: (a2: A2 | A, a: A) => A2): Stream; }; /** * Statefully and effectfully maps over the elements of this stream to produce * all intermediate results. * * See also `Stream.scanEffect`. * * @since 1.0.0 * @category utils */ export declare const scanReduceEffect: (f: (a2: A2 | A, a: A) => Effect.Effect) => (self: Stream) => Stream; /** * Schedules the output of the stream using the provided `schedule`. * * @since 1.0.0 * @category utils */ export declare const schedule: { (schedule: Schedule.Schedule): (self: Stream) => Stream; (self: Stream, schedule: Schedule.Schedule): Stream; }; /** * Schedules the output of the stream using the provided `schedule` and emits * its output at the end (if `schedule` is finite). Uses the provided function * to align the stream and schedule outputs on the same type. * * @since 1.0.0 * @category utils */ export declare const scheduleWith: { (schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C; }): (self: Stream) => Stream; (self: Stream, schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C; }): Stream; }; /** * Creates a single-valued stream from a scoped resource. * * @since 1.0.0 * @category constructors */ export declare const scoped: (effect: Effect.Effect) => Stream, E, A>; /** * Emits a sliding window of `n` elements. * * ```ts * import * as Stream from "@effect/stream/Stream" * import { pipe } from "@effect/data/Function" * * pipe( * Stream.make(1, 2, 3, 4), * Stream.sliding(2), * Stream.runCollect * ) * // => Chunk(Chunk(1, 2), Chunk(2, 3), Chunk(3, 4)) * ``` * * @since 1.0.0 * @category utils */ export declare const sliding: { (chunkSize: number): (self: Stream) => Stream>; (self: Stream, chunkSize: number): Stream>; }; /** * Like `sliding`, but with a configurable `stepSize` parameter. * * @since 1.0.0 * @category utils */ export declare const slidingSize: { (chunkSize: number, stepSize: number): (self: Stream) => Stream>; (self: Stream, chunkSize: number, stepSize: number): Stream>; }; /** * Converts an option on values into an option on errors. * * @since 1.0.0 * @category utils */ export declare const some: (self: Stream>) => Stream, A>; /** * Extracts the optional value, or returns the given 'default'. * * @since 1.0.0 * @category utils */ export declare const someOrElse: { (fallback: LazyArg): (self: Stream>) => Stream; (self: Stream>, fallback: LazyArg): Stream; }; /** * Extracts the optional value, or fails with the given error 'e'. * * @since 1.0.0 * @category utils */ export declare const someOrFail: { (error: LazyArg): (self: Stream>) => Stream; (self: Stream>, error: LazyArg): Stream; }; /** * Splits elements based on a predicate. * * ```ts * import * as Stream from "@effect/stream/Stream" * import { pipe } from "@effect/data/Function" * * pipe( * Stream.range(1, 10), * Stream.split((n) => n % 4 === 0), * Stream.runCollect * ) * // => Chunk(Chunk(1, 2, 3), Chunk(5, 6, 7), Chunk(9)) * ``` * * @since 1.0.0 * @category utils */ export declare const split: { (predicate: Predicate): (self: Stream) => Stream>; (self: Stream, predicate: Predicate): Stream>; }; /** * Splits elements on a delimiter and transforms the splits into desired output. * * @since 1.0.0 * @category utils */ export declare const splitOnChunk: { (delimiter: Chunk.Chunk): (self: Stream) => Stream>; (self: Stream, delimiter: Chunk.Chunk): Stream>; }; /** * Splits strings on newlines. Handles both Windows newlines (`\r\n`) and UNIX * newlines (`\n`). * * @since 1.0.0 * @category combinators */ export declare const splitLines: (self: Stream) => Stream; /** * Creates a single-valued pure stream. * * @since 1.0.0 * @category constructors */ export declare const succeed: (value: A) => Stream; /** * Creates a single-valued pure stream. * * @since 1.0.0 * @category constructors */ export declare const sync: (evaluate: LazyArg) => Stream; /** * Returns a lazily constructed stream. * * @since 1.0.0 * @category constructors */ export declare const suspend: (stream: LazyArg>) => Stream; /** * Takes the specified number of elements from this stream. * * @since 1.0.0 * @category utils */ export declare const take: { (n: number): (self: Stream) => Stream; (self: Stream, n: number): Stream; }; /** * Takes the last specified number of elements from this stream. * * @since 1.0.0 * @category utils */ export declare const takeRight: { (n: number): (self: Stream) => Stream; (self: Stream, n: number): Stream; }; /** * Takes all elements of the stream until the specified predicate evaluates to * `true`. * * @since 1.0.0 * @category utils */ export declare const takeUntil: { (predicate: Predicate): (self: Stream) => Stream; (self: Stream, predicate: Predicate): Stream; }; /** * Takes all elements of the stream until the specified effectual predicate * evaluates to `true`. * * @since 1.0.0 * @category utils */ export declare const takeUntilEffect: { (predicate: (a: A) => Effect.Effect): (self: Stream) => Stream; (self: Stream, predicate: (a: A) => Effect.Effect): Stream; }; /** * Takes all elements of the stream for as long as the specified predicate * evaluates to `true`. * * @since 1.0.0 * @category utils */ export declare const takeWhile: { (predicate: Predicate): (self: Stream) => Stream; (self: Stream, predicate: Predicate): Stream; }; /** * Adds an effect to consumption of every element of the stream. * * @since 1.0.0 * @category sequencing */ export declare const tap: { (f: (a: X) => Effect.Effect): (self: Stream) => Stream; (self: Stream, f: (a: X) => Effect.Effect): Stream; }; /** * Returns a stream that effectfully "peeks" at the failure or success of * the stream. * * @since 1.0.0 * @category sequencing */ export declare const tapBoth: { (options: { readonly onFailure: (e: XE) => Effect.Effect; readonly onSuccess: (a: XA) => Effect.Effect; }): (self: Stream) => Stream; (self: Stream, options: { readonly onFailure: (e: XE) => Effect.Effect; readonly onSuccess: (a: XA) => Effect.Effect; }): Stream; }; /** * Returns a stream that effectfully "peeks" at the failure of the stream. * * @since 1.0.0 * @category sequencing */ export declare const tapError: { (f: (error: X) => Effect.Effect): (self: Stream) => Stream; (self: Stream, f: (error: X) => Effect.Effect): Stream; }; /** * Returns a stream that effectfully "peeks" at the cause of failure of the * stream. * * @since 1.0.0 * @category utils */ export declare const tapErrorCause: { (f: (cause: Cause.Cause) => Effect.Effect): (self: Stream) => Stream; (self: Stream, f: (cause: Cause.Cause) => Effect.Effect): Stream; }; /** * Sends all elements emitted by this stream to the specified sink in addition * to emitting them. * * @since 1.0.0 * @category sequencing */ export declare const tapSink: { (sink: Sink.Sink): (self: Stream) => Stream; (self: Stream, sink: Sink.Sink): Stream; }; /** * Delays the chunks of this stream according to the given bandwidth * parameters using the token bucket algorithm. Allows for burst in the * processing of elements by allowing the token bucket to accumulate tokens up * to a `units + burst` threshold. The weight of each chunk is determined by * the `costFn` function. * * If using the "enforce" strategy, chunks that do not meet the bandwidth * constraints are dropped. If using the "shape" strategy, chunks are delayed * until they can be emitted without exceeding the bandwidth constraints. * * Defaults to the "shape" strategy. * * @since 1.0.0 * @category utils */ export declare const throttle: { (options: { readonly cost: (chunk: Chunk.Chunk) => number; readonly units: number; readonly duration: Duration.DurationInput; readonly burst?: number; readonly strategy?: "enforce" | "shape"; }): (self: Stream) => Stream; (self: Stream, options: { readonly cost: (chunk: Chunk.Chunk) => number; readonly units: number; readonly duration: Duration.DurationInput; readonly burst?: number; readonly strategy?: "enforce" | "shape"; }): Stream; }; /** * Delays the chunks of this stream according to the given bandwidth * parameters using the token bucket algorithm. Allows for burst in the * processing of elements by allowing the token bucket to accumulate tokens up * to a `units + burst` threshold. The weight of each chunk is determined by * the effectful `costFn` function. * * If using the "enforce" strategy, chunks that do not meet the bandwidth * constraints are dropped. If using the "shape" strategy, chunks are delayed * until they can be emitted without exceeding the bandwidth constraints. * * Defaults to the "shape" strategy. * * @since 1.0.0 * @category utils */ export declare const throttleEffect: { (options: { readonly cost: (chunk: Chunk.Chunk) => Effect.Effect; readonly units: number; readonly duration: Duration.DurationInput; readonly burst?: number; readonly strategy?: "enforce" | "shape"; }): (self: Stream) => Stream; (self: Stream, options: { readonly cost: (chunk: Chunk.Chunk) => Effect.Effect; readonly units: number; readonly duration: Duration.DurationInput; readonly burst?: number; readonly strategy?: "enforce" | "shape"; }): Stream; }; /** * A stream that emits Unit values spaced by the specified duration. * * @since 1.0.0 * @category constructors */ export declare const tick: (interval: Duration.DurationInput) => Stream; /** * Ends the stream if it does not produce a value after the specified duration. * * @since 1.0.0 * @category utils */ export declare const timeout: { (duration: Duration.DurationInput): (self: Stream) => Stream; (self: Stream, duration: Duration.DurationInput): Stream; }; /** * Fails the stream with given error if it does not produce a value after d * duration. * * @since 1.0.0 * @category utils */ export declare const timeoutFail: { (error: LazyArg, duration: Duration.DurationInput): (self: Stream) => Stream; (self: Stream, error: LazyArg, duration: Duration.DurationInput): Stream; }; /** * Fails the stream with given cause if it does not produce a value after d * duration. * * @since 1.0.0 * @category utils */ export declare const timeoutFailCause: { (cause: LazyArg>, duration: Duration.DurationInput): (self: Stream) => Stream; (self: Stream, cause: LazyArg>, duration: Duration.DurationInput): Stream; }; /** * Switches the stream if it does not produce a value after the specified * duration. * * @since 1.0.0 * @category utils */ export declare const timeoutTo: { (duration: Duration.DurationInput, that: Stream): (self: Stream) => Stream; (self: Stream, duration: Duration.DurationInput, that: Stream): Stream; }; /** * Converts the stream to a scoped hub of chunks. After the scope is closed, * the hub will never again produce values and should be discarded. * * @since 1.0.0 * @category destructors */ export declare const toHub: { (capacity: number): (self: Stream) => Effect.Effect>>; (self: Stream, capacity: number): Effect.Effect>>; }; /** * Returns in a scope a ZIO effect that can be used to repeatedly pull chunks * from the stream. The pull effect fails with None when the stream is * finished, or with Some error if it fails, otherwise it returns a chunk of * the stream's output. * * @since 1.0.0 * @category destructors */ export declare const toPull: (self: Stream) => Effect.Effect, Chunk.Chunk>>; /** * Converts the stream to a scoped queue of chunks. After the scope is closed, * the queue will never again produce values and should be discarded. * * Defaults to the "suspend" back pressure strategy with a capacity of 2. * * @since 1.0.0 * @category destructors */ export declare const toQueue: { (options?: { readonly strategy?: "dropping" | "sliding" | "suspend"; readonly capacity?: number; } | { readonly strategy: "unbounded"; }): (self: Stream) => Effect.Effect>>; (self: Stream, options?: { readonly strategy?: "dropping" | "sliding" | "suspend"; readonly capacity?: number; } | { readonly strategy: "unbounded"; }): Effect.Effect>>; }; /** * Converts the stream to a scoped queue of elements. After the scope is * closed, the queue will never again produce values and should be discarded. * * Defaults to a capacity of 2. * * @since 1.0.0 * @category destructors */ export declare const toQueueOfElements: { (options?: { readonly capacity?: number; }): (self: Stream) => Effect.Effect, A>>>; (self: Stream, options?: { readonly capacity?: number; }): Effect.Effect, A>>>; }; /** * Converts the stream to a `ReadableStream`. * * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream. * * @since 1.0.0 * @category destructors */ export declare const toReadableStream: (source: Stream) => ReadableStream; /** * Applies the transducer to the stream and emits its outputs. * * @since 1.0.0 * @category utils */ export declare const transduce: { (sink: Sink.Sink): (self: Stream) => Stream; (self: Stream, sink: Sink.Sink): Stream; }; /** * Creates a stream by peeling off the "layers" of a value of type `S`. * * @since 1.0.0 * @category constructors */ export declare const unfold: (s: S, f: (s: S) => Option.Option) => Stream; /** * Creates a stream by peeling off the "layers" of a value of type `S`. * * @since 1.0.0 * @category constructors */ export declare const unfoldChunk: (s: S, f: (s: S) => Option.Option, S]>) => Stream; /** * Creates a stream by effectfully peeling off the "layers" of a value of type * `S`. * * @since 1.0.0 * @category constructors */ export declare const unfoldChunkEffect: (s: S, f: (s: S) => Effect.Effect, S]>>) => Stream; /** * Creates a stream by effectfully peeling off the "layers" of a value of type * `S`. * * @since 1.0.0 * @category constructors */ export declare const unfoldEffect: (s: S, f: (s: S) => Effect.Effect>) => Stream; /** * A stream that contains a single `Unit` value. * * @since 1.0.0 * @category constructors */ export declare const unit: Stream; /** * Creates a stream produced from an `Effect`. * * @since 1.0.0 * @category constructors */ export declare const unwrap: (effect: Effect.Effect>) => Stream; /** * Creates a stream produced from a scoped `Effect`. * * @since 1.0.0 * @category constructors */ export declare const unwrapScoped: (effect: Effect.Effect>) => Stream, E | E2, A>; /** * Updates the specified service within the context of the `Stream`. * * @since 1.0.0 * @category context */ export declare const updateService: (>(tag: T, f: (service: Context.Tag.Service) => Context.Tag.Service) => (self: Stream) => Stream) & (>(self: Stream, tag: T_1, f: (service: Context.Tag.Service) => Context.Tag.Service) => Stream); /** * Returns the specified stream if the given condition is satisfied, otherwise * returns an empty stream. * * @since 1.0.0 * @category utils */ export declare const when: { (predicate: LazyArg): (self: Stream) => Stream; (self: Stream, predicate: LazyArg): Stream; }; /** * Returns the resulting stream when the given `PartialFunction` is defined * for the given value, otherwise returns an empty stream. * * @since 1.0.0 * @category constructors */ export declare const whenCase: (evaluate: LazyArg, pf: (a: A) => Option.Option>) => Stream; /** * Returns the stream when the given partial function is defined for the given * effectful value, otherwise returns an empty stream. * * @since 1.0.0 * @category utils */ export declare const whenCaseEffect: { (pf: (a: A) => Option.Option>): (self: Effect.Effect) => Stream; (self: Effect.Effect, pf: (a: A) => Option.Option>): Stream; }; /** * Returns the stream if the given effectful condition is satisfied, otherwise * returns an empty stream. * * @since 1.0.0 * @category utils */ export declare const whenEffect: { (effect: Effect.Effect): (self: Stream) => Stream; (self: Stream, effect: Effect.Effect): Stream; }; /** * Wraps the stream with a new span for tracing. * * @since 1.0.0 * @category tracing */ export declare const withSpan: { (name: string, options?: { readonly attributes?: Record; readonly links?: ReadonlyArray; readonly parent?: Tracer.ParentSpan; readonly root?: boolean; readonly context?: Context.Context; }): (self: Stream) => Stream; (self: Stream, name: string, options?: { readonly attributes?: Record; readonly links?: ReadonlyArray; readonly parent?: Tracer.ParentSpan; readonly root?: boolean; readonly context?: Context.Context; }): Stream; }; /** * Zips this stream with another point-wise and emits tuples of elements from * both streams. * * The new stream will end when one of the sides ends. * * @since 1.0.0 * @category zipping */ export declare const zip: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * Zips this stream with another point-wise and emits tuples of elements from * both streams. * * The new stream will end when one of the sides ends. * * @since 1.0.0 * @category zipping */ export declare const zipFlatten: { (that: Stream): >(self: Stream) => Stream; , R2, E2, A2>(self: Stream, that: Stream): Stream; }; /** * Zips this stream with another point-wise, creating a new stream of pairs of * elements from both sides. * * The defaults `defaultLeft` and `defaultRight` will be used if the streams * have different lengths and one of the streams has ended before the other. * * @since 1.0.0 * @category zipping */ export declare const zipAll: { (options: { readonly other: Stream; readonly defaultSelf: A; readonly defaultOther: A2; }): (self: Stream) => Stream; (self: Stream, options: { readonly other: Stream; readonly defaultSelf: A; readonly defaultOther: A2; }): Stream; }; /** * Zips this stream with another point-wise, and keeps only elements from this * stream. * * The provided default value will be used if the other stream ends before * this one. * * @since 1.0.0 * @category zipping */ export declare const zipAllLeft: { (that: Stream, defaultLeft: A): (self: Stream) => Stream; (self: Stream, that: Stream, defaultLeft: A): Stream; }; /** * Zips this stream with another point-wise, and keeps only elements from the * other stream. * * The provided default value will be used if this stream ends before the * other one. * * @since 1.0.0 * @category zipping */ export declare const zipAllRight: { (that: Stream, defaultRight: A2): (self: Stream) => Stream; (self: Stream, that: Stream, defaultRight: A2): Stream; }; /** * Zips this stream that is sorted by distinct keys and the specified stream * that is sorted by distinct keys to produce a new stream that is sorted by * distinct keys. Combines values associated with each key into a tuple, * using the specified values `defaultLeft` and `defaultRight` to fill in * missing values. * * This allows zipping potentially unbounded streams of data by key in * constant space but the caller is responsible for ensuring that the * streams are sorted by distinct keys. * * @since 1.0.0 * @category zipping */ export declare const zipAllSortedByKey: { (options: { readonly other: Stream; readonly defaultSelf: A; readonly defaultOther: A2; readonly order: Order.Order; }): (self: Stream) => Stream; (self: Stream, options: { readonly other: Stream; readonly defaultSelf: A; readonly defaultOther: A2; readonly order: Order.Order; }): Stream; }; /** * Zips this stream that is sorted by distinct keys and the specified stream * that is sorted by distinct keys to produce a new stream that is sorted by * distinct keys. Keeps only values from this stream, using the specified * value `default` to fill in missing values. * * This allows zipping potentially unbounded streams of data by key in * constant space but the caller is responsible for ensuring that the * streams are sorted by distinct keys. * * @since 1.0.0 * @category zipping */ export declare const zipAllSortedByKeyLeft: { (options: { readonly other: Stream; readonly defaultSelf: A; readonly order: Order.Order; }): (self: Stream) => Stream; (self: Stream, options: { readonly other: Stream; readonly defaultSelf: A; readonly order: Order.Order; }): Stream; }; /** * Zips this stream that is sorted by distinct keys and the specified stream * that is sorted by distinct keys to produce a new stream that is sorted by * distinct keys. Keeps only values from that stream, using the specified * value `default` to fill in missing values. * * This allows zipping potentially unbounded streams of data by key in * constant space but the caller is responsible for ensuring that the * streams are sorted by distinct keys. * * @since 1.0.0 * @category zipping */ export declare const zipAllSortedByKeyRight: { (options: { readonly other: Stream; readonly defaultOther: A2; readonly order: Order.Order; }): (self: Stream) => Stream; (self: Stream, options: { readonly other: Stream; readonly defaultOther: A2; readonly order: Order.Order; }): Stream; }; /** * Zips this stream that is sorted by distinct keys and the specified stream * that is sorted by distinct keys to produce a new stream that is sorted by * distinct keys. Uses the functions `left`, `right`, and `both` to handle * the cases where a key and value exist in this stream, that stream, or * both streams. * * This allows zipping potentially unbounded streams of data by key in * constant space but the caller is responsible for ensuring that the * streams are sorted by distinct keys. * * @since 1.0.0 * @category zipping */ export declare const zipAllSortedByKeyWith: { (options: { readonly other: Stream; readonly onSelf: (a: A) => A3; readonly onOther: (a2: A2) => A3; readonly onBoth: (a: A, a2: A2) => A3; readonly order: Order.Order; }): (self: Stream) => Stream; (self: Stream, options: { readonly other: Stream; readonly onSelf: (a: A) => A3; readonly onOther: (a2: A2) => A3; readonly onBoth: (a: A, a2: A2) => A3; readonly order: Order.Order; }): Stream; }; /** * Zips this stream with another point-wise. The provided functions will be * used to create elements for the composed stream. * * The functions `left` and `right` will be used if the streams have different * lengths and one of the streams has ended before the other. * * @since 1.0.0 * @category zipping */ export declare const zipAllWith: { (options: { readonly other: Stream; readonly onSelf: (a: A) => A3; readonly onOther: (a2: A2) => A3; readonly onBoth: (a: A, a2: A2) => A3; }): (self: Stream) => Stream; (self: Stream, options: { readonly other: Stream; readonly onSelf: (a: A) => A3; readonly onOther: (a2: A2) => A3; readonly onBoth: (a: A, a2: A2) => A3; }): Stream; }; /** * Zips the two streams so that when a value is emitted by either of the two * streams, it is combined with the latest value from the other stream to * produce a result. * * Note: tracking the latest value is done on a per-chunk basis. That means * that emitted elements that are not the last value in chunks will never be * used for zipping. * * @since 1.0.0 * @category zipping */ export declare const zipLatest: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * Zips the two streams so that when a value is emitted by either of the two * streams, it is combined with the latest value from the other stream to * produce a result. * * Note: tracking the latest value is done on a per-chunk basis. That means * that emitted elements that are not the last value in chunks will never be * used for zipping. * * @since 1.0.0 * @category zipping */ export declare const zipLatestWith: { (that: Stream, f: (a: A, a2: A2) => A3): (self: Stream) => Stream; (self: Stream, that: Stream, f: (a: A, a2: A2) => A3): Stream; }; /** * Zips this stream with another point-wise, but keeps only the outputs of * this stream. * * The new stream will end when one of the sides ends. * * @since 1.0.0 * @category zipping */ export declare const zipLeft: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * Zips this stream with another point-wise, but keeps only the outputs of the * other stream. * * The new stream will end when one of the sides ends. * * @since 1.0.0 * @category zipping */ export declare const zipRight: { (that: Stream): (self: Stream) => Stream; (self: Stream, that: Stream): Stream; }; /** * Zips this stream with another point-wise and applies the function to the * paired elements. * * The new stream will end when one of the sides ends. * * @since 1.0.0 * @category zipping */ export declare const zipWith: { (that: Stream, f: (a: A, a2: A2) => A3): (self: Stream) => Stream; (self: Stream, that: Stream, f: (a: A, a2: A2) => A3): Stream; }; /** * Zips this stream with another point-wise and applies the function to the * paired elements. * * The new stream will end when one of the sides ends. * * @since 1.0.0 * @category zipping */ export declare const zipWithChunks: { (that: Stream, f: (left: Chunk.Chunk, right: Chunk.Chunk) => readonly [Chunk.Chunk, Either.Either, Chunk.Chunk>]): (self: Stream) => Stream; (self: Stream, that: Stream, f: (left: Chunk.Chunk, right: Chunk.Chunk) => readonly [Chunk.Chunk, Either.Either, Chunk.Chunk>]): Stream; }; /** * Zips each element with the next element if present. * * @since 1.0.0 * @category zipping */ export declare const zipWithNext: (self: Stream) => Stream]>; /** * Zips each element with the previous element. Initially accompanied by * `None`. * * @since 1.0.0 * @category zipping */ export declare const zipWithPrevious: (self: Stream) => Stream, A]>; /** * Zips each element with both the previous and next element. * * @since 1.0.0 * @category zipping */ export declare const zipWithPreviousAndNext: (self: Stream) => Stream, A, Option.Option]>; /** * Zips this stream together with the index of elements. * * @since 1.0.0 * @category zipping */ export declare const zipWithIndex: (self: Stream) => Stream; /** * @since 1.0.0 * @category do notation */ export declare const Do: Stream; /** * Binds a value from a stream in a `do` scope * * @since 1.0.0 * @category do notation */ export declare const bind: { (tag: Exclude, f: (_: K) => Stream, options?: { readonly concurrency?: number | "unbounded"; readonly bufferSize?: number; }): (self: Stream) => Stream>; (self: Stream, tag: Exclude, f: (_: K) => Stream, options?: { readonly concurrency?: number | "unbounded"; readonly bufferSize?: number; }): Stream>; }; /** * Binds an effectful value in a `do` scope * * @since 1.0.0 * @category do notation */ export declare const bindEffect: { (tag: Exclude, f: (_: K) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded"; readonly bufferSize?: number; }): (self: Stream) => Stream>; (self: Stream, tag: Exclude, f: (_: K) => Effect.Effect, options?: { readonly concurrency?: number | "unbounded"; readonly bufferSize?: number; }): Stream>; }; /** * @since 1.0.0 * @category do notation */ export declare const bindTo: { (tag: N): (self: Stream) => Stream>; (self: Stream, tag: N): Stream>; }; declare const let_: { (tag: Exclude, f: (_: K) => A): (self: Stream) => Stream>; (self: Stream, tag: Exclude, f: (_: K) => A): Stream>; }; export { /** * Bind a value in a `do` scope * * @since 1.0.0 * @category do notation */ let_ as let }; /** * Decode Uint8Array chunks into a stream of strings using the specified encoding. * * @since 1.0.0 * @category encoding */ export declare const decodeText: { (encoding?: string): (self: Stream) => Stream; (self: Stream, encoding?: string): Stream; }; /** * Encode a stream of strings into a stream of Uint8Array chunks using the specified encoding. * * @since 1.0.0 * @category encoding */ export declare const encodeText: (self: Stream) => Stream; //# sourceMappingURL=Stream.d.ts.map