mapped-promise-all
v1.0.6
Published
Provides a mapping of the response of `Promise.all` to an object
Downloads
5
Readme
mapped-promise-all
Provides a mapping of the response of Promise.all
to an object.
Install
$ npm i mapped-promise-all
// or
$ yarn add mapped-promise-all
Usage
import { mappedPromiseAll } from 'mapped-promise-all';
const getUser = async () => ({
name: 'user',
email: '[email protected]',
});
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
Contribution
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.