Basic usage

A reduce that handles callback functions that return a promise.

import { reduce } from 'radash'

const userIds = [1, 2, 3, 4]

const users = await reduce(userIds, async (acc, userId) => {
  const user = await api.users.find(userId)
  return {
    ...acc,
    [userId]: user
  }
}, {})

Testing

This _.reduce function is 100% covered by tests. See them and contribute at GitHub.

Source

See the source for _.reduce on GitHub.