Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

light-promise

dracupid10MIT0.1.1

A Super Lightweight promise/A+ implementation

promise, promise/A+

readme

Promises/A+ logo

light-promise

A Super Lightweight Promise/A+ and ES6-promise implementation, tested by promises-tests and promises-es6-tests

This project mainly focus on Promise/A+, with some tricks to fulfill ES6-promise standard.

NPM version Build Status Build status

js-standard-style

Usage

Node

Run npm install -S light-promise in command line. Then,

let Promise = require('light-promise')

Browser

Download the light-promise.min.js file.

Light-promise is also a bower package.

  • Add a script tag in your HTML file
    <script src="/light-promise.js"></script>
  • The global variables Promise is available after the above script tag.
    • Notice that if the browser supports Promise natively, Promise variable will keep to be the native one, which I recommend you to use.
      var p = new Promise(function(resolve, reject){
      // ...
      })
      p.then(function(){})

      You can also use light-promise with requirejs or browserify as well.

API

  • Object Methods

new Promise(Function<Function resolve, Function reject> resolver)
.then([Function onFulfilled] [, Function onRejected])
.catch(Function onRejected)

  • Static Methods

Promise.resolve(Dynamic value)
Promise.reject(Dynamic reason)
Promise.all(Array promises) --extended method
Promise.race(Array promises) --extended method

Test

npm test