2022-01-21 08:28:41 +00:00
|
|
|
var nextHandle = 1;
|
2022-06-08 10:36:39 +00:00
|
|
|
var resolved;
|
2022-01-21 08:28:41 +00:00
|
|
|
var activeHandles = {};
|
|
|
|
function findAndClearHandle(handle) {
|
|
|
|
if (handle in activeHandles) {
|
|
|
|
delete activeHandles[handle];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
export var Immediate = {
|
|
|
|
setImmediate: function (cb) {
|
|
|
|
var handle = nextHandle++;
|
|
|
|
activeHandles[handle] = true;
|
2022-06-08 10:36:39 +00:00
|
|
|
if (!resolved) {
|
|
|
|
resolved = Promise.resolve();
|
|
|
|
}
|
|
|
|
resolved.then(function () { return findAndClearHandle(handle) && cb(); });
|
2022-01-21 08:28:41 +00:00
|
|
|
return handle;
|
|
|
|
},
|
|
|
|
clearImmediate: function (handle) {
|
|
|
|
findAndClearHandle(handle);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
export var TestTools = {
|
|
|
|
pending: function () {
|
|
|
|
return Object.keys(activeHandles).length;
|
|
|
|
}
|
|
|
|
};
|
2022-06-08 10:36:39 +00:00
|
|
|
//# sourceMappingURL=Immediate.js.map
|