You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
479 B
20 lines
479 B
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
|