1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var nextHandle = 1;
|
4 | var RESOLVED = (function () { return Promise.resolve(); })();
|
5 | var activeHandles = {};
|
6 | function findAndClearHandle(handle) {
|
7 | if (handle in activeHandles) {
|
8 | delete activeHandles[handle];
|
9 | return true;
|
10 | }
|
11 | return false;
|
12 | }
|
13 | exports.Immediate = {
|
14 | setImmediate: function (cb) {
|
15 | var handle = nextHandle++;
|
16 | activeHandles[handle] = true;
|
17 | RESOLVED.then(function () { return findAndClearHandle(handle) && cb(); });
|
18 | return handle;
|
19 | },
|
20 | clearImmediate: function (handle) {
|
21 | findAndClearHandle(handle);
|
22 | },
|
23 | };
|
24 | exports.TestTools = {
|
25 | pending: function () {
|
26 | return Object.keys(activeHandles).length;
|
27 | }
|
28 | };
|
29 |
|
\ | No newline at end of file |