/** * @short * *Reduces* yielded values to a single one by repeatedly invoking a reducer. * * @categories * static * * @description * Applies a reducer function against the accumulator and each yielded value * from the source iterable to reduce it to a single value. After iteration * is done, returns the most recently determined accumulator. * * If a seed is given, then that value will be used as the initial value for * the accumulator. Otherwise, the first yielded value of the source iterable * will be used instead. * * An empty iterable with no given seed with throw an error. * * @since * 0.0.1 * * @parameter * iterable * Iterable * The source iterable to be reduced. * * @parameter * reducer * (accumulator: U, value: T, index: number) => U * The reducer function invoked for each yielded value. * * @parameter * seed [optional] * U * The accumulator value to be used for the first iteration. If not given, the first * value itself is used as the seed, and the first iteration is skipped. * * @returns * U * * @example * const input = [1, 2, 3, 4] * const reducer = (a: number, b: number) => a + b * j.Reduce(input, reducer) * // => 10 * * @example * const input = [1, 2, 3, 4] * const reducer = (a: number, b: number) => a + b * j.Reduce(input, reducer, 0) * // => 10 * * @example * const reducer = (a: number, b: number) => a + b * j.Reduce([], reducer) * // (!) TypeError * * @example * const reducer = (a: number, b: number) => a + b * j.Reduce([], reducer, 0) * // => 0 */ export declare function Reduce(iterable: Iterable, reducer: (accumulator: U, value: T, index: number) => U, seed: U): U; export declare function Reduce(iterable: Iterable, reducer: (accumulator: T, value: T, index: number) => T, seed?: T): T;