UNPKG

geninq

Version:

A JavaScript version of the Linq library for Generators

56 lines (55 loc) 3.1 kB
import { Promised } from "./utils"; declare global { interface Generator<T = unknown, TReturn = any, TNext = unknown> { /** * Applies an accumulator function over a sequence. * @param aggregator An accumulator function to be invoked on each element. * @returns The transformed final accumulator value. */ aggregate(aggregator: (current: T, next: T) => T): T; /** * Applies an accumulator function over a sequence. * The specified seed value is used as the initial accumulator value. * @param acc The initial accumulator value. * @param aggregator An accumulator function to be invoked on each element. * @returns The transformed final accumulator value. */ aggregate<TAcc>(acc: TAcc, aggregator: (current: TAcc, next: T) => TAcc): TAcc; /** * Applies an accumulator function over a sequence. * The specified seed value is used as the initial accumulator value, * and the specified function is used to select the result value. * @param acc The initial accumulator value. * @param aggregator An accumulator function to be invoked on each element. * @param selector A function to transform the final accumulator value into the result value. * @returns The transformed final accumulator value. */ aggregate<TAcc, TResult>(acc: TAcc, aggregator: (current: TAcc, next: T) => TAcc, selector: (part: TAcc) => TResult): TResult; } interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> { /** * Applies an accumulator function over a sequence. * @param aggregator An accumulator function to be invoked on each element. * @returns The transformed final accumulator value. */ aggregate(aggregator: (current: T, next: T) => Promised<T>): Promise<T>; /** * Applies an accumulator function over a sequence. * The specified seed value is used as the initial accumulator value. * @param acc The initial accumulator value. * @param aggregator An accumulator function to be invoked on each element. * @returns The transformed final accumulator value. */ aggregate<TAcc>(acc: TAcc, aggregator: (current: TAcc, next: T) => Promised<TAcc>): Promise<TAcc>; /** * Applies an accumulator function over a sequence. * The specified seed value is used as the initial accumulator value, * and the specified function is used to select the result value. * @param acc The initial accumulator value. * @param aggregator An accumulator function to be invoked on each element. * @param selector A function to transform the final accumulator value into the result value. * @returns The transformed final accumulator value. */ aggregate<TAcc, TResult>(acc: TAcc, aggregator: (current: TAcc, next: T) => Promised<TAcc>, selector: (part: TAcc) => Promised<TResult>): Promise<TResult>; } }