import { type Flat, type Mapping, type Predicate } from './iterables.js'; /** * {@label Iter} * Chain iterable operations, each acting on the output of the previous step * @example When the action is per item, the result is accessible as *iterable* * ``` * chain([0,1,2]) * .filter(i => i) * .map(i => i**2) * .iterable * // => [1,4] * ``` * @example When the action returns an element (as in first, next, reduce etc) the the result is accessible as *value* * ``` * chain([0,1,2]).filter(i => i).first().value * // => 1 * ``` * @example Iterable is always accessible, as a single element iterable * ``` * chain([0,1,2]).filter(i => i).first().iterable * // => [1] * ``` * @example Note if the action returned undefined, iterable will be empty * ``` * chain([]).first().iterable // => [] * chain([]).first().value // => undefined * ``` * @param value - initial iterable * @returns Chainable action on iterable */ export declare function chain(value: Iterable): IterableChain; /** * {@label Iter} * Chain iterable operations, each acting on the output of the previous step * @example When the action is per item, the result is accessible as *iterable* * ``` * chain([0,1,2]) * .filter(i => i) * .map(i => i**2) * .iterable * // => [1,4] * ``` * @example When the action returns an element (as in first, next, reduce etc) the the result is accessible as *value* * ``` * chain("hello").map(i => i.split("")).first().value * // => "h" * ``` * @example Iterable is always accessible, as a single element iterable * ``` * chain([0,1,2]).filter(i => i).first().iterable * // => [1] * ``` * @example Note if the action returned undefined, iterable will be empty * ``` * chain([]).first().iterable // => [] * chain([]).first().value // => undefined * ``` * @param value - initial value * @returns Chainable action on iterable */ export declare function chain>(value: V): ValueChain; export type IterableChain = Chain & { value: Iterable; }; export type ValueChain = Chain & { value: T; }; export type NotIterable = T extends Iterable ? never : T; export type Iter = T extends Iterable ? Iterable : Iterable; export type Chain = { last: () => ValueChain; first: () => ValueChain; isEmpty: () => ValueChain; size: () => ValueChain; at: (index: number) => ValueChain; next: () => ValueChain; prev: () => ValueChain; unique: () => IterableChain; map: (m: Mapping) => IterableChain; flatMap: (m: Mapping) => IterableChain>; filter: (p: Predicate) => IterableChain; concat: (...iterables: Iterable[]) => IterableChain; forEach: (fn: Mapping) => IterableChain; find: (p: Predicate) => ValueChain; includes: (element: T) => ValueChain; some: (p: Predicate) => ValueChain; sort: (p: Predicate) => IterableChain; every: (p: Predicate) => ValueChain; flat: () => IterableChain>; join: () => ValueChain; skip: (count: number) => IterableChain; reduce: (reducer: (acc: A, item: T) => A, initial: A) => ValueChain; iterable: Iterable; get array(): T[]; }; //# sourceMappingURL=chain.d.ts.map