@irrelon/promise-map
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

Irrelon PromiseMap

This micro-helper allows you to do a Promise.all() except instead of passing an array of promises that you then extract via array indices you can pass an object of key / values with each value being a promise and then extract resolved values by key name instead:

const result = await promiseMap({
    foo: fetch("https://www.google.com"),
    bar: someOtherPromise
});

// result.foo is now the fetch response
// result.bar is the response from your other theoretical promise

Install

npm i @irrelon/promise-map

Usage

TypeScript and ES6 Modules

import {promiseMap} from "@irrelon/promise-map";

CommonJS

const {promiseMap} = require("@irrelon/promise-map").default;

Readme

Keywords

Package Sidebar

Install

npm i @irrelon/promise-map

Weekly Downloads

67

Version

2.0.3

License

ISC

Unpacked Size

67.1 kB

Total Files

20

Last publish

Collaborators

  • coolbloke1324