import isFunction from "lodash/isFunction";
/**
* queues a microtask to be executed at a safe time prior to control returning to the browser's event loop.
* @author Aamir khan
*/
const taskQueuePatch = function taskQueuePatch() {
const self = window || global || {};
if (!isFunction(self.queueMicrotask)) {
self.queueMicrotask = function queueMicrotask(callback) {
Promise.resolve()
.then(callback)
.catch(e => setTimeout(() => { throw e; })); // report exceptions
};
}
return self.queueMicrotask
}
const taskQueue = taskQueuePatch();
export default taskQueue;