21 lines
480 B
JavaScript
Raw Normal View History

let nextHandle = 1;
const tasksByHandle = {};
function runIfPresent(handle) {
const cb = tasksByHandle[handle];
if (cb) {
cb();
}
}
export const Immediate = {
setImmediate(cb) {
const handle = nextHandle++;
tasksByHandle[handle] = cb;
Promise.resolve().then(() => runIfPresent(handle));
return handle;
},
clearImmediate(handle) {
delete tasksByHandle[handle];
},
};
//# sourceMappingURL=Immediate.js.map