promise-a-plus
Version:
A JavaScript Promise/A+ Library.
45 lines (29 loc) • 1.98 kB
Markdown
# promise-a-plus
[](https://badge.fury.io/js/promise-a-plus)
[](https://travis-ci.org/creeperyang/promise-a-plus)
[](https://coveralls.io/github/creeperyang/promise-a-plus?branch=master)
[](https://david-dm.org/creeperyang/promise-a-plus)
[](https://david-dm.org/creeperyang/promise-a-plus#info=devDependencies)
[](https://www.npmjs.com/package/promise-a-plus)
<a href="https://promisesaplus.com/">
<img src="https://promisesaplus.com/assets/logo-small.png" alt="Promises/A+ logo" title="Promises/A+ 1.0 compliant" align="right" />
</a>
This is a JavaScript implementation of [*Promises/A+* spec](https://github.com/promises-aplus/promises-spec), and adequately tested.
Also a full featured polyfill for *ES6 Promise*.
## Install
[](https://nodei.co/npm/promise-a-plus/)
## Usage
```js
var Promise = require('promise-a-plus');
var promise1 = Promise.resolve('nice');
var promise2 = new Promise(function(resolve, reject) {
reject('just rejected');
});
Promise.race([promise1, promise2]).then(console.log.bind(console));
```
If you want to use in browser, use tools like `webpack` or `browserify`.
## API
The library's API is absolutely consistent with [official API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
Also view [wiki](https://github.com/creeperyang/promise-a-plus/wiki/API).
## License
Copyright (c) 2015 creeperyang. Licensed under the MIT license.