I don't want to unnecessarily complicate the first example, but should the asap = setTimeout; bit be changed like so?
var asap;
var isNode = typeof process !== "undefined" &&
{}.toString.call(process) === "[object process]";
if (isNode) {
asap = process.nextTick;
} else if (typeof setImmediate !== "undefined") {
asap = setImmediate;
} else {
asap = function(fn) {
setTimeout(fn, 0);
};
}
export default asap;
Aside: because setImmediate returns an id value, you'd probably want to wrap it in a function to prevent a value being returned. Well, if you were designing a real API.
I don't want to unnecessarily complicate the first example, but should the
asap = setTimeout;bit be changed like so?Aside: because
setImmediatereturns an id value, you'd probably want to wrap it in a function to prevent a value being returned. Well, if you were designing a real API.