es6-promise / 3.2.1 last updated a month ago created on Dec 16th 2013

Install

npm install --save es6-promise

Clone

git clone git@github.com:jakearchibald/ES6-Promises.git

dependencies

No dependencies listed.

maintainers

jaffathecake
stefanpenner

versions 15 total

3.2.1 a month ago stefanpenner
3.1.2 4 months ago stefanpenner
3.0.2 10 months ago stefanpenner
3.0.1 10 months ago stefanpenner
3.0.0 10 months ago stefanpenner
2.3.0 a year ago jaffathecake
2.2.0 a year ago jaffathecake
2.1.1 a year ago jaffathecake
2.1.0 a year ago jaffathecake
2.0.1 2 years ago jaffathecake
2.0.0 2 years ago jaffathecake
1.0.0 2 years ago jaffathecake
0.1.2 2 years ago jaffathecake
0.1.1 3 years ago jaffathecake
0.1.0 3 years ago jaffathecake
144834 Downloads yesterday.

readme

ES6-Promise (subset of rsvp.js)

This is a polyfill of the ES6 Promise. The implementation is a subset of rsvp.js extracted by @jakearchibald, if you're wanting extra features and more debugging options, check out the full library.

For API details and how to use promises, see the JavaScript Promises HTML5Rocks article.

Downloads

Node.js

To install:

npm install es6-promise

To use:

var Promise = require('es6-promise').Promise;

Bower

To install:

bower install es6-promise --save

Usage in IE<9

catch is a reserved word in IE<9, meaning promise.catch(func) throws a syntax error. To work around this, you can use a string to access the property as shown in the following example.

However, please remember that such technique is already provided by most common minifiers, making the resulting code safe for old browsers and production:

1
2
3
promise['catch'](function(err) {
  // ...
});

Or use .then instead:

1
2
3
promise.then(undefined, function(err) {
  // ...
});

Auto-polyfill

To polyfill the global environment (either in Node or in the browser via CommonJS) use the following code snippet:

require('es6-promise').polyfill();

Notice that we don't assign the result of polyfill() to any variable. The polyfill() method will patch the global environment (in this case to the Promise name) when called.

Building & Testing

You will need to have PhantomJS installed globally in order to run the tests.

npm install -g phantomjs

  • npm run build to build
  • npm test to run tests
  • npm start to run a build watcher, and webserver to test
  • npm run test:server for a testem test runner and watching builder
Resolving all dependencies.. This could take a while as our cache is not yet fully warmed up.