@vanilla-enhance/epromise
enhance vanilla Promise to provide practical usage.
Table of Contents
-
Highlights - Usage
-
APIs
- Static
- all
- Warnings
all
//arg is object whose keys is of string and values is of promise.
static async all<T>(inMap: Record<string, Promise<T>>): Promise<Record<string, T>>
//arg is array whose all values are promises.
static async all<T>(inputMap: Promise<T>[]): Promise<T[]>
for example:
import {EPromise} from '@vanilla-enhance/epromise';
EPromise.all({
one:new Promise(resolve=>{
setTimeout(_=>{
resolve('haha1')
},3000)
}),
two:new Promise(resolve=>{
setTimeout(_=>{
resolve('haha2')
},1000)
}),
three:Promise.resolve(3),
}).then(console.log) //=>{ one: 'haha1', two: 'haha2', three: 3 }
Changelog
The changelog can be found on the Releases page.
Contributing
Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.
Authors and license
XiaohuLiu and contributors.
MIT License, see the included License.md file.