Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. Function.prototype.catch = function(callback) {
  2. const f = this;
  3. return function(...args) {
  4. try {
  5. const v = f.apply(this, args);
  6. if ('then' in v && 'catch' in v) {
  7. return v.catch(callback);
  8. }
  9. return v;
  10. } catch (err) {
  11. return callback(err);
  12. }
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement