GithubHelp home page GithubHelp logo

evenloooo / es6-promise Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stefanpenner/es6-promise

0.0 1.0 0.0 654 KB

A polyfill for ES6-style Promises

License: MIT License

JavaScript 99.49% HTML 0.51%

es6-promise's Introduction

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:

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

Or use .then instead:

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

es6-promise's People

Contributors

cyril-sf avatar domenic avatar fivetanley avatar greenkeeperio-bot avatar jakearchibald avatar joseluisq avatar josh avatar karlbohlmark avatar kt3k avatar lukemelia avatar machty avatar matthew-andrews avatar mikepmunroe avatar necolas avatar nmn avatar omichelsen avatar pangratz avatar rwaldron avatar rwjblue avatar ryanflorence avatar stefanpenner avatar teddyzeenny avatar tomdale avatar twokul avatar ukyo avatar vicb avatar wagenet avatar webreflection avatar wibblymat avatar wycats avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.