Globals to add
Opened this issue · 6 comments
chicoxyzzy commented
styfle commented
Does Promise
belong in the globals list?
ljharb commented
That’s already a language builtin; what needs to be added?
littledan commented
setTimeout
joyeecheung commented
The full range of global timer functions in Node.js:
- clearImmediate
- clearInterval
- clearTimeout
- setImmediate
- setInterval
- setTimeout
There are also queueMicrotask
which is experimental, and WebAssembly which comes from V8. (Node.js's console is not entirely from V8 depending on where you are accessing it)
joyeecheung commented
Also Node.js implements parts of the Performance Timing API but it's still experimental and I don't recall plans to make it a global. It is intentionally different from the browser in some cases (e.g. nodejs/node#19563)
joyeecheung commented
BTW this script can be used to find Node.js-specific globals:
'use strict';
const vm = require('vm');
const globalsFromVM = JSON.parse(
JSON.stringify(
vm.runInNewContext('Reflect.ownKeys(globalThis)')
)
);
const globalsFromNode = [];
for (const key of Reflect.ownKeys(globalThis)) {
if (!globalsFromVM.includes(key)) {
globalsFromNode.push(key);
}
}
console.log(globalsFromNode.map(key => String(key)).join('\n'))