@vanilla-enhance/epromise
TypeScript icon, indicating that this package has built-in type declarations

0.0.3-1 • Public • Published

@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.

Readme

Keywords

Package Sidebar

Install

npm i @vanilla-enhance/epromise

Weekly Downloads

0

Version

0.0.3-1

License

ISC

Unpacked Size

28.3 kB

Total Files

13

Last publish

Collaborators

  • ninja009