Provides a mapping of the response of Promise.all
to an object.
$ npm i mapped-promise-all
// or
$ yarn add mapped-promise-all
import { mappedPromiseAll } from 'mapped-promise-all';
const getUser = async () => ({
name: 'user',
email: 'sample@example.com',
});
const getItems = async () => [
{ id: 1, name: 'item 1' },
{ id: 2, name: 'item 2' },
];
mappedPromiseAll({
user: getUser(),
items: getItems(),
}).then(({ user, items }) => {
// do something
});
// async/await
const { user, items } = await mappedPromiseAll({
user: getUser(),
items: getItems(),
});
// do something
If you find a bug or want to contribute to the code or documentation, you can help by submitting an issue or a pull request.