1.0.6 • Published 5 years ago

mapped-promise-all v1.0.6

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

mapped-promise-all

npm version License: MIT CI

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: '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

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.

License

MIT

1.0.6

5 years ago

1.0.2

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago