done.js 314 B

1234567891011121314
  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. };