done.js 314 B

12345678910111213
  1. 'use strict';
  2. var Promise = require('./core.js');
  3. module.exports = Promise;
  4. Promise.prototype.done = function (onFulfilled, onRejected) {
  5. var self = arguments.length ? this.then.apply(this, arguments) : this;
  6. self.then(null, function (err) {
  7. setTimeout(function () {
  8. throw err;
  9. }, 0);
  10. });
  11. };