web.queue-microtask.js 584 B

12345678910111213141516
  1. var $ = require('../internals/export');
  2. var global = require('../internals/global');
  3. var microtask = require('../internals/microtask');
  4. var classof = require('../internals/classof-raw');
  5. var process = global.process;
  6. var isNode = classof(process) == 'process';
  7. // `queueMicrotask` method
  8. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask
  9. $({ global: true, enumerable: true, noTargetGet: true }, {
  10. queueMicrotask: function queueMicrotask(fn) {
  11. var domain = isNode && process.domain;
  12. microtask(domain ? domain.bind(fn) : fn);
  13. }
  14. });