0.1.1 • Published 8 years ago

light-promise v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

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
0.1.1

8 years ago

0.1.0

8 years ago

0.0.4

8 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago