0.0.3-1 • Published 2 years ago
@vanilla-enhance/epromise v0.0.3-1
@vanilla-enhance/epromise
enhance vanilla Promise to provide practical usage.
Table of Contents
comment: <> (Highlights)
comment: <> ()
comment: <> ( )
comment: <> ( all)
comment: <> ( )
comment: <> ( )
comment: <> ( enable to resolve objects with values of promise.)
comment: <> ( )
comment: <> ( )
comment: <> ( )
//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 }
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.