promiseReduce.d.ts 524 B

12345678910111213
  1. import type { PromiseOrValue } from './PromiseOrValue';
  2. /**
  3. * Similar to Array.prototype.reduce(), however the reducing callback may return
  4. * a Promise, in which case reduction will continue after each promise resolves.
  5. *
  6. * If the callback does not return a Promise, then this function will also not
  7. * return a Promise.
  8. */
  9. export declare function promiseReduce<T, U>(
  10. values: Iterable<T>,
  11. callbackFn: (accumulator: U, currentValue: T) => PromiseOrValue<U>,
  12. initialValue: PromiseOrValue<U>,
  13. ): PromiseOrValue<U>;