import { AsyncReducer, ItemType, KeysOfType, Reducer } from '../base'; export type BaseChainKeyType = string | symbol | number; export type ChainKeyType = BaseChainKeyType | Iterable; export type ToObjectChainFuncMap = (x: T) => ChainKeyType; export type ToObjectChainKey = KeysOfType | ToObjectChainFuncMap; export type Indexes = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1 ]; export type ToObjectChainValueOf> = K extends ToObjectChainFuncMap ? ReturnType : K extends keyof V ? V[K] : never; export type RecordChain>, V, R = V[], Pos extends number = 0> = { done: R; any: any; recur: ToObjectChainValueOf extends BaseChainKeyType ? Record, RecordChain> : ToObjectChainValueOf extends Iterable ? Record>, RecordChain> : never; }[Pos extends Arr['length'] ? 'done' : Pos extends -1 ? 'any' : 'recur']; export interface ToObjectChainFunction { /** * Creates an object chain with the values of the specified fields where the latest * value in the chain will be the iterable item itself. This is a resolving operation * @param keys The keys to be chained * @returns The object chain */ >>(...keys: A): RecordChain; } export interface AsyncToObjectChainFunction { /** * Creates an object chain with the values of the specified fields where the latest * value in the chain will be the iterable item itself. This is a resolving operation * @param keys The keys to be chained. It can be either property names or mapping functions * @returns The object chain */ >>(...keys: A): Promise>; } export interface ToObjectChainReduceFunction { /** * Creates an object chain with the values of the specified fields where the latest * value in the chain will be the iterable item itself. This is a resolving operation * @param initial An initializer function to define the base value for each leaf * @param reduce: A reduce function to accumulate the leaf value for each value that fits it * @param keys The keys to be chained. It can be either property names or mapping functions * @returns The object chain */ >, R>(initial: () => R, reduce: Reducer, ...keys: A): RecordChain; } export interface AsyncToObjectChainReduceFunction { /** * Creates an object chain with the values of the specified fields where the latest * value in the chain will be the iterable item itself. This is a resolving operation * @param initial An initializer function to define the base value for each leaf * @param reduce: A reduce function to accumulate the leaf value for each value that fits it * @param keys The keys to be chained. It can be either property names or mapping functions * @returns The object chain */ >, R>(initial: () => R, reduce: AsyncReducer, ...keys: A): Promise>; }