enhance vanilla Promise to provide practical usage.
Highlights- Usage
- APIs
- Static
- all
- Warnings
//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[]>
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 }
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 }
The changelog can be found on the Releases page.
Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.
XiaohuLiu and contributors.
MIT License, see the included License.md file.