Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. var Promise = require('bluebird');
  2. var inherits = require('inherits');
  3. var extend = require('xtend/mutable');
  4.  
  5. function FantasyPromise() {
  6. return new (Promise.bind.apply(Promise, [this].concat([].slice.call(arguments))));
  7. }
  8.  
  9. inherits(FantasyPromise, Promise);
  10. extend(FantasyPromis, Promise);
  11.  
  12. FantasyPromise.prototype.chain = function(fn) {
  13. var that = this;
  14. return new FantasyPromise(function(resolve, reject) {
  15. that.then(function(v) {
  16. return fn(v).then(resolve);
  17. }).catch(reject);
  18. });
  19. };
  20.  
  21. FantasyPromise.of = Promise.resolve;
  22.  
  23. module.exports = FantasyPromise;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement