import type {Arg0, Ret, AsFlatList, Fn} from './defs'; export = gen; /** * Returns a wrapped identity function. Rarely used. */ declare function gen(): (arg: unknown) => AsyncGenerator; /** * Returns a function that applies the given functions in sequence wrapping them as * an asynchronous generator. * @param fns functions to be wrapped * @returns an asynchronous generator */ declare function gen( ...fns: gen.FnList, L> ): AsFlatList extends readonly [Fn, ...Fn[]] ? (arg: Arg0) => AsyncGenerator, void, unknown> : (arg: unknown) => AsyncGenerator; declare namespace gen { /** * Returns a type, which was expected from a list item. * It is used to highlight mismatches between argument types and return types in a list. */ type FnItem = F extends readonly [infer F1, ...infer R] ? F1 extends null | undefined ? readonly [F1, ...FnList] : readonly [FnItem, ...FnList, R>] : F extends readonly unknown[] ? readonly [FnItem] : F extends Fn ? I extends Arg0 ? F : (arg: I, ...rest: readonly unknown[]) => ReturnType : F extends null | undefined ? F : never; /** * Replicates a tuple verifying the types of the list items so arguments match returns. * The replicated tuple is used to highlight mismatches between list items. */ type FnList = L extends readonly [infer F1, ...infer R] ? F1 extends null | undefined ? readonly [F1, ...FnList] : readonly [FnItem, ...FnList, R>] : L; }