Closed benlesh closed 1 year ago
asyncIterable.reduce
To be clear, these methods are on iterators, not on iterables. There is no generic "async iterable" class where we could put stuff.
To answer the question: Promise<number>
.
This is similar to the sync versions, where e.g. syncIterator.reduce((acc, n) => acc + n, 0)
will return a number, rather than an iterator of one value.
(Closing as answered but feel free to re-open if there's more.)
I couldn't quite make it out from reading the spec HTML in the repo.
For example,
asyncIterable.reduce((acc, n) => acc + n, 0)
does that return aPromise<number>
or anAsyncIterable<number>
.It seems like the
Promise<number>
would be more useful in a world with async await, however, it would mean that any other APIs that want to follow suit don't have a predictable template to follow... then again,Array#reduce
can return anything at all, andArray#find
(et al) don't return an array, they return the value.