Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Immediate.js 479B

1234567891011121314151617181920
  1. let nextHandle = 1;
  2. const tasksByHandle = {};
  3. function runIfPresent(handle) {
  4. const cb = tasksByHandle[handle];
  5. if (cb) {
  6. cb();
  7. }
  8. }
  9. export const Immediate = {
  10. setImmediate(cb) {
  11. const handle = nextHandle++;
  12. tasksByHandle[handle] = cb;
  13. Promise.resolve().then(() => runIfPresent(handle));
  14. return handle;
  15. },
  16. clearImmediate(handle) {
  17. delete tasksByHandle[handle];
  18. },
  19. };
  20. //# sourceMappingURL=Immediate.js.map