Skip to content

ninja-liu/vanilla-enhance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@vanilla-enhance/epromise


enhance vanilla Promise to provide practical usage.

Table of Contents


Usage


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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published