Skip to content

🍊 An implementation of Promises/A+ using ES6, and Chinese specification of Promises/A+.

License

Notifications You must be signed in to change notification settings

mingmingwon/a-promise-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Promises/A+ Logo

npm npm GitHub

Introduction

An implementation of Promises/A+ using ES6, and Chinese specification of Promises/A+.

Install

NPM

npm i a-promise-lib

Usage

let Promise = require('a-promise-lib')

let promise = new Promise((resolve, reject) => {
  setTimeout(resolve, 1000, 'Success')
}).then(res => {
  console.log(res)
  return Promise.resolve('Yeah')
})

;(async () => {
  const ret = await promise
  console.log(ret)
})()

API

This library has achieved all the APIs same as JavaScript Standard built-in Promise, including static methods:

  • Promise.resolve
  • Promise.reject
  • Promise.all
  • Promise.race

and prototype methods:

  • Promise.prototype.then
  • Promise.prototype.catch
  • Promise.prototype.finally

and others:

  • Promise.deferred
  • Promise.prototype.done

Compliances Test

Refer to Promises/A+ Compliance Test Suite.

npm run test

Result like this:

872 passing (17s)

License

The MIT License

About

🍊 An implementation of Promises/A+ using ES6, and Chinese specification of Promises/A+.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published