Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # ES6-Promise (subset of [rsvp.js](https://github.com/tildeio/rsvp.js))
  2. This is a polyfill of the [ES6 Promise](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-constructor). The implementation is a subset of [rsvp.js](https://github.com/tildeio/rsvp.js) extracted by @jakearchibald, if you're wanting extra features and more debugging options, check out the [full library](https://github.com/tildeio/rsvp.js).
  3. For API details and how to use promises, see the <a href="http://www.html5rocks.com/en/tutorials/es6/promises/">JavaScript Promises HTML5Rocks article</a>.
  4. ## Downloads
  5. * [es6-promise](https://raw.githubusercontent.com/stefanpenner/es6-promise/master/dist/es6-promise.js)
  6. * [es6-promise-min](https://raw.githubusercontent.com/stefanpenner/es6-promise/master/dist/es6-promise.min.js)
  7. ## Node.js
  8. To install:
  9. ```sh
  10. npm install es6-promise
  11. ```
  12. To use:
  13. ```js
  14. var Promise = require('es6-promise').Promise;
  15. ```
  16. ## Bower
  17. To install:
  18. ```sh
  19. bower install es6-promise --save
  20. ```
  21. ## Usage in IE<9
  22. `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.
  23. However, please remember that such technique is already provided by most common minifiers, making the resulting code safe for old browsers and production:
  24. ```js
  25. promise['catch'](function(err) {
  26. // ...
  27. });
  28. ```
  29. Or use `.then` instead:
  30. ```js
  31. promise.then(undefined, function(err) {
  32. // ...
  33. });
  34. ```
  35. ## Auto-polyfill
  36. To polyfill the global environment (either in Node or in the browser via CommonJS) use the following code snippet:
  37. ```js
  38. require('es6-promise').polyfill();
  39. ```
  40. 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.
  41. ## Building & Testing
  42. You will need to have PhantomJS installed globally in order to run the tests.
  43. `npm install -g phantomjs`
  44. * `npm run build` to build
  45. * `npm test` to run tests
  46. * `npm start` to run a build watcher, and webserver to test
  47. * `npm run test:server` for a testem test runner and watching builder