Skip to content

Commit

Permalink
lib: move queueMicrotask to stable
Browse files Browse the repository at this point in the history
PR-URL: #25594
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
  • Loading branch information
devsnek committed Mar 8, 2019
1 parent b05fd4b commit 9f1282d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 26 deletions.
2 changes: 0 additions & 2 deletions doc/api/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ added: v11.0.0

<!-- type=global -->

> Stability: 1 - Experimental
* `callback` {Function} Function to be queued.

The `queueMicrotask()` method queues a microtask to invoke `callback`. If
Expand Down
28 changes: 5 additions & 23 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,30 +396,12 @@ function createGlobalConsole(consoleFromVM) {
}

function setupQueueMicrotask() {
const { queueMicrotask } =
NativeModule.require('internal/queue_microtask');
Object.defineProperty(global, 'queueMicrotask', {
get() {
process.emitWarning('queueMicrotask() is experimental.',
'ExperimentalWarning');
const { queueMicrotask } =
NativeModule.require('internal/queue_microtask');

Object.defineProperty(global, 'queueMicrotask', {
value: queueMicrotask,
writable: true,
enumerable: false,
configurable: true,
});
return queueMicrotask;
},
set(v) {
Object.defineProperty(global, 'queueMicrotask', {
value: v,
writable: true,
enumerable: false,
configurable: true,
});
},
enumerable: false,
value: queueMicrotask,
writable: true,
enumerable: true,
configurable: true,
});
}
Expand Down
3 changes: 2 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ let knownGlobals = [
global,
setImmediate,
setInterval,
setTimeout
setTimeout,
queueMicrotask,
];

if (global.gc) {
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ builtinModules.forEach((moduleName) => {
{
const expected = [
'global',
'queueMicrotask',
'clearImmediate',
'clearInterval',
'clearTimeout',
Expand Down

0 comments on commit 9f1282d

Please sign in to comment.