Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
684 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | let nextHandle = 1;
|
---|
| 2 | const RESOLVED = (() => Promise.resolve())();
|
---|
| 3 | const activeHandles = {};
|
---|
| 4 | function findAndClearHandle(handle) {
|
---|
| 5 | if (handle in activeHandles) {
|
---|
| 6 | delete activeHandles[handle];
|
---|
| 7 | return true;
|
---|
| 8 | }
|
---|
| 9 | return false;
|
---|
| 10 | }
|
---|
| 11 | export const Immediate = {
|
---|
| 12 | setImmediate(cb) {
|
---|
| 13 | const handle = nextHandle++;
|
---|
| 14 | activeHandles[handle] = true;
|
---|
| 15 | RESOLVED.then(() => findAndClearHandle(handle) && cb());
|
---|
| 16 | return handle;
|
---|
| 17 | },
|
---|
| 18 | clearImmediate(handle) {
|
---|
| 19 | findAndClearHandle(handle);
|
---|
| 20 | },
|
---|
| 21 | };
|
---|
| 22 | export const TestTools = {
|
---|
| 23 | pending() {
|
---|
| 24 | return Object.keys(activeHandles).length;
|
---|
| 25 | }
|
---|
| 26 | };
|
---|
| 27 | //# sourceMappingURL=Immediate.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.