Immediate.js 816 B

12345678910111213141516171819202122232425262728
  1. /** PURE_IMPORTS_START PURE_IMPORTS_END */
  2. var nextHandle = 1;
  3. var RESOLVED = /*@__PURE__*/ (function () { return /*@__PURE__*/ Promise.resolve(); })();
  4. var activeHandles = {};
  5. function findAndClearHandle(handle) {
  6. if (handle in activeHandles) {
  7. delete activeHandles[handle];
  8. return true;
  9. }
  10. return false;
  11. }
  12. export var Immediate = {
  13. setImmediate: function (cb) {
  14. var handle = nextHandle++;
  15. activeHandles[handle] = true;
  16. RESOLVED.then(function () { return findAndClearHandle(handle) && cb(); });
  17. return handle;
  18. },
  19. clearImmediate: function (handle) {
  20. findAndClearHandle(handle);
  21. },
  22. };
  23. export var TestTools = {
  24. pending: function () {
  25. return Object.keys(activeHandles).length;
  26. }
  27. };
  28. //# sourceMappingURL=Immediate.js.map