call(back)

mapAsync I

Implement mapAsync(items, fn): call an async mapping function fn(item) (it returns a promise) on every item at once, and resolve with the results in input order.

  • Results come back in input order, whatever order the calls finish in.
  • items can be any iterable, not only an array. An empty input resolves to [].
  • Reject with the first rejection.

Your helper runs on a virtual clock, and the grader's fn logs when each call starts and settles.

Hints

Hint 1

Array.from(items, fn) turns any iterable into an array of promises, starting every call.

Hint 2

Promise.all keeps input order and rejects with the first rejection.

Asked at