Skip to content

Commit

Permalink
add a fix for Bun queueMicrotask arity
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Mar 4, 2024
1 parent 59a342d commit 79ace5c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
##### Unreleased
- Fixed some validation cases in `Object.setPrototypeOf`, [#1329](https://github.com/zloirock/core-js/issues/1329), thanks [**@minseok-choe**](https://github.com/minseok-choe)
- Fixed the order of validations in `Array.from`, [#1331](https://github.com/zloirock/core-js/pull/1331), thanks [**@minseok-choe**](https://github.com/minseok-choe)
- Added a fix of [Bun `queueMicrotask` arity](https://github.com/oven-sh/bun/issues/9249)
- Compat data improvements:
- Added React Native 0.74 Hermes compat data, `Array.prototype.{ toSpliced, toReversed, with }` and `atob` marked as supported
- Added Opera Android 81 compat data mapping
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js-compat/src/data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2549,7 +2549,8 @@ export const data = {
node: '0.9.1',
},
'web.queue-microtask': {
bun: '0.1.1',
// wrong arity in Bun ~ 1.0.30, https://github.com/oven-sh/bun/issues/9249
// bun: '0.1.1',
chrome: '71',
deno: '1.0',
firefox: '69',
Expand Down
13 changes: 12 additions & 1 deletion packages/core-js/modules/web.queue-microtask.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
'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 experemental 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 }, {
$({ global: true, enumerable: true, dontCallGetSet: true, forced: WRONG_ARITY }, {
queueMicrotask: function queueMicrotask(fn) {
validateArgumentsLength(arguments.length, 1);
microtask(aCallable(fn));
Expand Down

0 comments on commit 79ace5c

Please sign in to comment.