SHARE
TWEET

Untitled

a guest Apr 19th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top