github-pages-deploy-action/node_modules/rxjs/_esm2015/internal/util/Immediate.js

27 lines
684 B
JavaScript
Raw Normal View History

2020-03-07 11:45:40 +08:00
let nextHandle = 1;
const RESOLVED = (() => Promise.resolve())();
const activeHandles = {};
function findAndClearHandle(handle) {
if (handle in activeHandles) {
delete activeHandles[handle];
return true;
}
return false;
}
export const Immediate = {
setImmediate(cb) {
const handle = nextHandle++;
activeHandles[handle] = true;
RESOLVED.then(() => findAndClearHandle(handle) && cb());
return handle;
},
clearImmediate(handle) {
findAndClearHandle(handle);
},
};
export const TestTools = {
pending() {
return Object.keys(activeHandles).length;
}
};
//# sourceMappingURL=Immediate.js.map