import "../../Operator/index.js"; import type * as C from "../../Cause/index.js"; import * as Chunk from "../../Collections/Immutable/Chunk/index.js"; import type { Predicate, Refinement } from "../../Function/index.js"; import * as O from "../../Option/index.js"; import * as T from "../_internal/effect.js"; import * as M from "../_internal/managed.js"; export declare class Transducer { readonly push: M.Managed>) => T.Effect>>; constructor(push: M.Managed>) => T.Effect>>); } /** * Contract notes for transducers: * - When a None is received, the transducer must flush all of its internal state * and remain empty until subsequent Some(Chunk) values. * * Stated differently, after a first push(None), all subsequent push(None) must * result in empty []. */ export declare const transducer: (push: M.Managed>) => T.Effect>>) => Transducer; /** * Compose this transducer with another transducer, resulting in a composite transducer. */ export declare const andThen: (that: Transducer) => (self: Transducer) => Transducer; /** * Transforms the outputs of this transducer. */ export declare function map_(fa: Transducer, f: (o: O) => O1): Transducer; /** * Transforms the outputs of this transducer. */ export declare function map(f: (o: O) => P): (fa: Transducer) => Transducer; /** * Transforms the chunks emitted by this transducer. */ export declare function mapChunks_(fa: Transducer, f: (chunks: Chunk.Chunk) => Chunk.Chunk): Transducer; /** * Transforms the chunks emitted by this transducer. */ export declare function mapChunks(f: (chunks: Chunk.Chunk) => Chunk.Chunk): (fa: Transducer) => Transducer; /** * Effectfully transforms the chunks emitted by this transducer. */ export declare function mapChunksM_(fa: Transducer, f: (chunk: Chunk.Chunk) => T.Effect>): Transducer; /** * Effectfully transforms the chunks emitted by this transducer. */ export declare function mapChunksM(f: (chunk: Chunk.Chunk) => T.Effect>): (fa: Transducer) => Transducer; /** * Effectually transforms the outputs of this transducer */ export declare function mapM_(fa: Transducer, f: (o: O) => T.Effect): Transducer; /** * Effectually transforms the outputs of this transducer */ export declare function mapM(f: (o: O) => T.Effect): (fa: Transducer) => Transducer; /** * Transforms the errors of this transducer. */ export declare function mapError_(pab: Transducer, f: (e: E) => E1): Transducer; /** * Transforms the errors of this transducer. */ export declare function mapError(f: (e: E) => E1): (pab: Transducer) => Transducer; /** * Creates a transducer that always fails with the specified failure. */ export declare function fail(e: E): Transducer; /** * Creates a transducer that always dies with the specified exception. */ export declare function die(error: unknown): Transducer; /** * Creates a transducer that always fails with the specified cause. */ export declare function halt(c: C.Cause): Transducer; /** * The identity transducer. Passes elements through. */ export declare function identity(): Transducer; /** * Creates a transducer from a chunk processing function. */ export declare function fromPush(push: (input: O.Option>) => T.Effect>): Transducer; /** * Creates a transducer that always evaluates the specified effect. */ export declare function fromEffect(task: T.Effect): Transducer; /** * Creates a transducer that purely transforms incoming values. */ export declare function fromFunction(f: (i: I) => O): Transducer; /** * Creates a transducer that effectfully transforms incoming values. */ export declare function fromFunctionM(f: (i: I) => T.Effect): Transducer; /** * Creates a transducer that returns the first element of the stream, if it exists. */ export declare function head(): Transducer>; /** * Creates a transducer that returns the last element of the stream, if it exists. */ export declare function last(): Transducer>; /** * Emits the provided chunk before emitting any other value. */ export declare function prepend(values: Chunk.Chunk): Transducer; /** * Reads the first n values from the stream and uses them to choose the transducer that will be used for the remainder of the stream. * If the stream ends before it has collected n values the partial chunk will be provided to f. */ export declare function branchAfter(n: number, f: (c: Chunk.Chunk) => Transducer): Transducer; /** * Creates a transducer that starts consuming values as soon as one fails * the predicate `p`. */ export declare function dropWhile(predicate: Predicate): Transducer; /** * Creates a transducer that starts consuming values as soon as one fails * the effectful predicate `p`. */ export declare function dropWhileM(p: (i: I) => T.Effect): Transducer; /** * Creates a transducer by folding over a structure of type `O` for as long as * `contFn` results in `true`. The transducer will emit a value when `contFn` * evaluates to `false` and then restart the folding. */ export declare function fold(initial: O, contFn: (o: O) => boolean, f: (output: O, input: I) => O): Transducer; /** * Creates a transducer by folding over a structure of type `O`. The transducer will * fold the inputs until the stream ends, resulting in a stream with one element. */ export declare function foldLeft(initial: O, f: (output: O, input: I) => O): Transducer; /** * Creates a sink by effectfully folding over a structure of type `S`. */ export declare function foldM(initial: O, contFn: (o: O) => boolean, f: (output: O, input: I) => T.Effect): Transducer; /** * Creates a transducer by effectfully folding over a structure of type `O`. The transducer will * fold the inputs until the stream ends, resulting in a stream with one element. */ export declare function foldLeftM(initial: O, f: (output: O, input: I) => T.Effect): Transducer; /** * Creates a transducer that folds elements of type `I` into a structure * of type `O` until `max` elements have been folded. * * Like `foldWeighted`, but with a constant cost function of 1. */ export declare function foldUntil(initial: O, max: number, f: (output: O, input: I) => O): Transducer; /** * Creates a transducer that effectfully folds elements of type `I` into a structure * of type `O` until `max` elements have been folded. * * Like `foldWeightedM`, but with a constant cost function of 1. */ export declare function foldUntilM(initial: O, max: number, f: (output: O, input: I) => T.Effect): Transducer; /** * Creates a transducer that folds elements of type `I` into a structure * of type `O`, until `max` worth of elements (determined by the `costFn`) * have been folded. * * The `decompose` function will be used for decomposing elements that * cause an `O` aggregate to cross `max` into smaller elements. * * Be vigilant with this function, it has to generate "simpler" values * or the fold may never end. A value is considered indivisible if * `decompose` yields the empty chunk or a single-valued chunk. In * these cases, there is no other choice than to yield a value that * will cross the threshold. * * The foldWeightedDecomposeM allows the decompose function * to return an `Effect` value, and consequently it allows the transducer * to fail. */ export declare function foldWeightedDecompose(initial: O, costFn: (output: O, input: I) => number, max: number, decompose: (input: I) => Chunk.Chunk, f: (output: O, input: I) => O): Transducer; /** * Creates a transducer that effectfully folds elements of type `I` into a structure * of type `S`, until `max` worth of elements (determined by the `costFn`) have * been folded. * * The `decompose` function will be used for decomposing elements that * cause an `S` aggregate to cross `max` into smaller elements. Be vigilant with * this function, it has to generate "simpler" values or the fold may never end. * A value is considered indivisible if `decompose` yields the empty chunk or a * single-valued chunk. In these cases, there is no other choice than to yield * a value that will cross the threshold. * * See foldWeightedDecompose for an example. */ export declare function foldWeightedDecomposeM(initial: O, costFn: (output: O, input: I) => T.Effect, max: number, decompose: (input: I) => T.Effect>, f: (output: O, input: I) => T.Effect): Transducer; /** * Creates a transducer that folds elements of type `I` into a structure * of type `O`, until `max` worth of elements (determined by the `costFn`) * have been folded. * * @note Elements that have an individual cost larger than `max` will * force the transducer to cross the `max` cost. See `foldWeightedDecompose` * for a variant that can handle these cases. */ export declare function foldWeighted(initial: O, costFn: (o: O, i: I) => number, max: number, f: (o: O, i: I) => O): Transducer; /** * Creates a transducer accumulating incoming values into chunks of maximum size `n`. */ export declare function collectAllN(n: number): Transducer>; /** * Creates a transducer accumulating incoming values into maps of up to `n` keys. Elements * are mapped to keys using the function `key`; elements mapped to the same key will * be merged with the function `f`. */ export declare function collectAllToMapN(n: number, key: (i: I) => K, merge: (i: I, i1: I) => I): Transducer>; /** * Accumulates incoming elements into a chunk as long as they verify predicate `p`. */ export declare function collectAllWhile(p: Predicate): Transducer>; /** * Accumulates incoming elements into a chunk as long as they verify effectful predicate `p`. */ export declare function collectAllWhileM(p: (i: I) => T.Effect): Transducer>; /** * Filters the outputs of this transducer. */ export declare function filter_(fa: Transducer, predicate: Predicate): Transducer; export declare function filter_(fa: Transducer, refinement: Refinement): Transducer; /** * Filters the outputs of this transducer. */ export declare function filter(predicate: Predicate): (fa: Transducer) => Transducer; export declare function filter(refinement: Refinement): (fa: Transducer) => Transducer; /** * Filters the inputs of this transducer. */ export declare function filterInput_(fa: Transducer, predicate: Predicate): Transducer; export declare function filterInput_(fa: Transducer, refinement: Refinement): Transducer; /** * Filters the inputs of this transducer. */ export declare function filterInput(predicate: Predicate): (fa: Transducer) => Transducer; export declare function filterInput(refinement: Refinement): (fa: Transducer) => Transducer; /** * Effectually filters the inputs of this transducer. */ export declare function filterInputM_(fa: Transducer, predicate: (i: I) => T.Effect): Transducer; /** * Effectually filters the inputs of this transducer. */ export declare function filterInputM(predicate: (i: I) => T.Effect): (fa: Transducer) => Transducer; /** * Creates a transducer produced from an effect. */ export declare function unwrap(effect: T.Effect>): Transducer; /** * Creates a transducer produced from a managed effect. */ export declare function unwrapManaged(managed: M.Managed>): Transducer; //# sourceMappingURL=index.d.ts.map