wishthis/node_modules/rxjs/dist/cjs/internal/util/Immediate.js

33 lines
891 B
JavaScript
Raw Normal View History

2022-01-21 08:28:41 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
2022-06-08 10:36:39 +00:00
exports.TestTools = exports.Immediate = void 0;
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;
}
exports.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);
},
};
exports.TestTools = {
pending: function () {
return Object.keys(activeHandles).length;
}
};
//# sourceMappingURL=Immediate.js.map