nicolas-van/modern-async

For `reduce` and `reduceRight` it should be possible to use any type for accumulator

Closed this issue · 1 comments

For now it is strictly fixed to iterator item type

Yes, it's something that should be fixed in the TypeScript definitions:

declare module "reduce" {
    export default reduce;
    function reduce<V>(iterable: Iterable<V> | AsyncIterable<V>, reducer: (accumulator: V, value: V, index: number, iterable: Iterable<V> | AsyncIterable<V>) => Promise<V> | V, initial?: V): Promise<V>;
}
declare module "reduceRight" {
    export default reduceRight;
    function reduceRight<V>(iterable: Iterable<V> | AsyncIterable<V>, reducer: (accumulator: V, value: V, index: number, iterable: Iterable<V> | AsyncIterable<V>) => Promise<V> | V, initial?: V): Promise<V>;
}