Last active
December 20, 2015 08:39
-
-
Save rkatic/6102488 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var asap = require("asap") | |
asap.sub = function (onerror) { | |
var parent = this; | |
var self = function (task) { | |
parent(function () { | |
try { | |
task(); | |
} catch (e) { | |
if (self.onerror) { | |
self.onerror(e); | |
} else { | |
throw e; | |
} | |
} | |
}); | |
}; | |
self.onerror = onerror; | |
self.sub = parent.sub; | |
return self; | |
}; | |
module.exports = asap.sub.bind(asap); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// asap for easier debugging in browsers. | |
var asap = require("asap.sub")(function (e) { | |
if (typeof window !== "undefined") { | |
if (window.console && console.error) { | |
console.error(e); | |
return; | |
} | |
} | |
throw e; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment