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.
27 lines
684 B
27 lines
684 B
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
|