web.queue-microtask.js 749 B

12345678910111213141516171819
  1. var $ = require('../internals/export');
  2. var global = require('../internals/global');
  3. var microtask = require('../internals/microtask');
  4. var aCallable = require('../internals/a-callable');
  5. var validateArgumentsLength = require('../internals/validate-arguments-length');
  6. var IS_NODE = require('../internals/engine-is-node');
  7. var process = global.process;
  8. // `queueMicrotask` method
  9. // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask
  10. $({ global: true, enumerable: true, dontCallGetSet: true }, {
  11. queueMicrotask: function queueMicrotask(fn) {
  12. validateArgumentsLength(arguments.length, 1);
  13. aCallable(fn);
  14. var domain = IS_NODE && process.domain;
  15. microtask(domain ? domain.bind(fn) : fn);
  16. }
  17. });