-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
web.queue-microtask.js
25 lines (23 loc) · 1.06 KB
/
web.queue-microtask.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';
var $ = require('../internals/export');
var globalThis = require('../internals/global');
var microtask = require('../internals/microtask');
var aCallable = require('../internals/a-callable');
var validateArgumentsLength = require('../internals/validate-arguments-length');
var fails = require('../internals/fails');
var DESCRIPTORS = require('../internals/descriptors');
// Bun ~ 1.0.30 bug
// https://github.com/oven-sh/bun/issues/9249
var WRONG_ARITY = fails(function () {
// getOwnPropertyDescriptor for prevent experimental warning in Node 11
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
return DESCRIPTORS && Object.getOwnPropertyDescriptor(globalThis, 'queueMicrotask').value.length !== 1;
});
// `queueMicrotask` method
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask
$({ global: true, enumerable: true, dontCallGetSet: true, forced: WRONG_ARITY }, {
queueMicrotask: function queueMicrotask(fn) {
validateArgumentsLength(arguments.length, 1);
microtask(aCallable(fn));
}
});