{ "type": "module", "source": "doc/api/globals.md", "introduced_in": "v0.10.0", "globals": [ { "textRaw": "Class: `AbortController`", "type": "global", "name": "AbortController", "meta": { "added": [ "v15.0.0", "v14.17.0" ], "changes": [ { "version": "v15.4.0", "pr-url": "https://github.com/nodejs/node/pull/35949", "description": "No longer experimental." } ] }, "desc": "
A utility class used to signal cancelation in selected Promise
-based APIs.\nThe API is based on the Web API AbortController
.
const ac = new AbortController();\n\nac.signal.addEventListener('abort', () => console.log('Aborted!'),\n { once: true });\n\nac.abort();\n\nconsole.log(ac.signal.aborted); // Prints true\n
",
"methods": [
{
"textRaw": "`abortController.abort([reason])`",
"type": "method",
"name": "abort",
"meta": {
"added": [
"v15.0.0",
"v14.17.0"
],
"changes": [
{
"version": [
"v17.2.0",
"v16.14.0"
],
"pr-url": "https://github.com/nodejs/node/pull/40807",
"description": "Added the new optional reason argument."
}
]
},
"signatures": [
{
"params": [
{
"textRaw": "`reason` {any} An optional reason, retrievable on the `AbortSignal`'s `reason` property.",
"name": "reason",
"type": "any",
"desc": "An optional reason, retrievable on the `AbortSignal`'s `reason` property."
}
]
}
],
"desc": "Triggers the abort signal, causing the abortController.signal
to emit\nthe 'abort'
event.
The AbortSignal
is used to notify observers when the\nabortController.abort()
method is called.
Returns a new already aborted AbortSignal
.
Returns a new AbortSignal
which will be aborted in delay
milliseconds.
Returns a new AbortSignal
which will be aborted if any of the provided\nsignals are aborted. Its abortSignal.reason
will be set to whichever\none of the signals
caused it to be aborted.
The 'abort'
event is emitted when the abortController.abort()
method\nis called. The callback is invoked with a single object argument with a\nsingle type
property set to 'abort'
:
const ac = new AbortController();\n\n// Use either the onabort property...\nac.signal.onabort = () => console.log('aborted!');\n\n// Or the EventTarget API...\nac.signal.addEventListener('abort', (event) => {\n console.log(event.type); // Prints 'abort'\n}, { once: true });\n\nac.abort();\n
\nThe AbortController
with which the AbortSignal
is associated will only\never trigger the 'abort'
event once. We recommended that code check\nthat the abortSignal.aborted
attribute is false
before adding an 'abort'
\nevent listener.
Any event listeners attached to the AbortSignal
should use the\n{ once: true }
option (or, if using the EventEmitter
APIs to attach a\nlistener, use the once()
method) to ensure that the event listener is\nremoved as soon as the 'abort'
event is handled. Failure to do so may\nresult in memory leaks.
An optional callback function that may be set by user code to be notified\nwhen the abortController.abort()
function has been called.
An optional reason specified when the AbortSignal
was triggered.
const ac = new AbortController();\nac.abort(new Error('boom!'));\nconsole.log(ac.signal.reason); // Error: boom!\n
"
}
],
"methods": [
{
"textRaw": "`abortSignal.throwIfAborted()`",
"type": "method",
"name": "throwIfAborted",
"meta": {
"added": [
"v17.3.0",
"v16.17.0"
],
"changes": []
},
"signatures": [
{
"params": []
}
],
"desc": "If abortSignal.aborted
is true
, throws abortSignal.reason
.
See <Blob>.
" }, { "textRaw": "Class: `Buffer`", "type": "global", "name": "Buffer", "meta": { "added": [ "v0.1.103" ], "changes": [] }, "desc": "Used to handle binary data. See the buffer section.
" }, { "textRaw": "`clearImmediate(immediateObject)`", "type": "global", "name": "clearImmediate", "meta": { "added": [ "v0.9.1" ], "changes": [] }, "desc": "clearImmediate
is described in the timers section.
clearInterval
is described in the timers section.
clearTimeout
is described in the timers section.
Used to print to stdout and stderr. See the console
section.
A browser-compatible implementation of the CustomEvent
Web API.
A browser-compatible implementation of the Event
class. See\nEventTarget
and Event
API for more details.
A browser-compatible implementation of the EventTarget
class. See\nEventTarget
and Event
API for more details.
See <File>.
" }, { "textRaw": "`global`", "name": "`global`", "meta": { "added": [ "v0.1.27" ], "changes": [] }, "type": "global", "stability": 3, "stabilityText": "Legacy. Use [`globalThis`][] instead.", "desc": "In browsers, the top-level scope has traditionally been the global scope. This\nmeans that var something
will define a new global variable, except within\nECMAScript modules. In Node.js, this is different. The top-level scope is not\nthe global scope; var something
inside a Node.js module will be local to that\nmodule, regardless of whether it is a CommonJS module or an\nECMAScript module.
The MessageChannel
class. See MessageChannel
for more details.
The MessageEvent
class. See MessageEvent
for more details.
The MessagePort
class. See MessagePort
for more details.
The PerformanceEntry
class. See PerformanceEntry
for more details.
The PerformanceMark
class. See PerformanceMark
for more details.
The PerformanceMeasure
class. See PerformanceMeasure
for more details.
The PerformanceObserver
class. See PerformanceObserver
for more details.
The PerformanceObserverEntryList
class. See\nPerformanceObserverEntryList
for more details.
The PerformanceResourceTiming
class. See PerformanceResourceTiming
for\nmore details.
The process object. See the process
object section.
callback
<Function> Function to be queued.The queueMicrotask()
method queues a microtask to invoke callback
. If\ncallback
throws an exception, the process
object 'uncaughtException'
\nevent will be emitted.
The microtask queue is managed by V8 and may be used in a similar manner to\nthe process.nextTick()
queue, which is managed by Node.js. The\nprocess.nextTick()
queue is always processed before the microtask queue\nwithin each turn of the Node.js event loop.
// Here, `queueMicrotask()` is used to ensure the 'load' event is always\n// emitted asynchronously, and therefore consistently. Using\n// `process.nextTick()` here would result in the 'load' event always emitting\n// before any other promise jobs.\n\nDataHandler.prototype.load = async function load(key) {\n const hit = this._cache.get(key);\n if (hit !== undefined) {\n queueMicrotask(() => {\n this.emit('load', hit);\n });\n return;\n }\n\n const data = await fetchData(key);\n this._cache.set(key, data);\n this.emit('load', data);\n};\n
"
},
{
"textRaw": "`setImmediate(callback[, ...args])`",
"type": "global",
"name": "setImmediate",
"meta": {
"added": [
"v0.9.1"
],
"changes": []
},
"desc": "setImmediate
is described in the timers section.
setInterval
is described in the timers section.
setTimeout
is described in the timers section.
The WHATWG structuredClone
method.
The WHATWG DOMException
class. See DOMException
for more details.
The WHATWG TextDecoder
class. See the TextDecoder
section.
The WHATWG TextEncoder
class. See the TextEncoder
section.
The WHATWG URL
class. See the URL
section.
The WHATWG URLSearchParams
class. See the URLSearchParams
section.
The object that acts as the namespace for all W3C\nWebAssembly related functionality. See the\nMozilla Developer Network for usage and compatibility.
" } ], "classes": [ { "textRaw": "Class: `ByteLengthQueuingStrategy`", "type": "class", "name": "ByteLengthQueuingStrategy", "meta": { "added": [ "v18.0.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental.", "desc": "A browser-compatible implementation of ByteLengthQueuingStrategy
.
A browser-compatible implementation of CompressionStream
.
A browser-compatible implementation of CountQueuingStrategy
.
A browser-compatible implementation of DecompressionStream
.
A browser-compatible implementation of ReadableByteStreamController
.
A browser-compatible implementation of ReadableStream
.
A browser-compatible implementation of ReadableStreamBYOBReader
.
A browser-compatible implementation of ReadableStreamBYOBRequest
.
A browser-compatible implementation of ReadableStreamDefaultController
.
A browser-compatible implementation of ReadableStreamDefaultReader
.
A browser-compatible implementation of TextDecoderStream
.
A browser-compatible implementation of TextEncoderStream
.
A browser-compatible implementation of TransformStream
.
A browser-compatible implementation of TransformStreamDefaultController
.
A browser-compatible implementation of WritableStream
.
A browser-compatible implementation of WritableStreamDefaultController
.
A browser-compatible implementation of WritableStreamDefaultWriter
.
Global alias for buffer.atob()
.
Global alias for buffer.btoa()
.
This variable may appear to be global but is not. See require()
.
These objects are available in all modules.
\nThe following variables may appear to be global but are not. They exist only in\nthe scope of CommonJS modules:
\n__dirname
__filename
exports
module
require()
The objects listed here are specific to Node.js. There are built-in objects\nthat are part of the JavaScript language itself, which are also globally\naccessible.
", "globals": [ { "textRaw": "Class: `AbortController`", "type": "global", "name": "AbortController", "meta": { "added": [ "v15.0.0", "v14.17.0" ], "changes": [ { "version": "v15.4.0", "pr-url": "https://github.com/nodejs/node/pull/35949", "description": "No longer experimental." } ] }, "desc": "A utility class used to signal cancelation in selected Promise
-based APIs.\nThe API is based on the Web API AbortController
.
const ac = new AbortController();\n\nac.signal.addEventListener('abort', () => console.log('Aborted!'),\n { once: true });\n\nac.abort();\n\nconsole.log(ac.signal.aborted); // Prints true\n
",
"methods": [
{
"textRaw": "`abortController.abort([reason])`",
"type": "method",
"name": "abort",
"meta": {
"added": [
"v15.0.0",
"v14.17.0"
],
"changes": [
{
"version": [
"v17.2.0",
"v16.14.0"
],
"pr-url": "https://github.com/nodejs/node/pull/40807",
"description": "Added the new optional reason argument."
}
]
},
"signatures": [
{
"params": [
{
"textRaw": "`reason` {any} An optional reason, retrievable on the `AbortSignal`'s `reason` property.",
"name": "reason",
"type": "any",
"desc": "An optional reason, retrievable on the `AbortSignal`'s `reason` property."
}
]
}
],
"desc": "Triggers the abort signal, causing the abortController.signal
to emit\nthe 'abort'
event.
The AbortSignal
is used to notify observers when the\nabortController.abort()
method is called.
Returns a new already aborted AbortSignal
.
Returns a new AbortSignal
which will be aborted in delay
milliseconds.
Returns a new AbortSignal
which will be aborted if any of the provided\nsignals are aborted. Its abortSignal.reason
will be set to whichever\none of the signals
caused it to be aborted.
The 'abort'
event is emitted when the abortController.abort()
method\nis called. The callback is invoked with a single object argument with a\nsingle type
property set to 'abort'
:
const ac = new AbortController();\n\n// Use either the onabort property...\nac.signal.onabort = () => console.log('aborted!');\n\n// Or the EventTarget API...\nac.signal.addEventListener('abort', (event) => {\n console.log(event.type); // Prints 'abort'\n}, { once: true });\n\nac.abort();\n
\nThe AbortController
with which the AbortSignal
is associated will only\never trigger the 'abort'
event once. We recommended that code check\nthat the abortSignal.aborted
attribute is false
before adding an 'abort'
\nevent listener.
Any event listeners attached to the AbortSignal
should use the\n{ once: true }
option (or, if using the EventEmitter
APIs to attach a\nlistener, use the once()
method) to ensure that the event listener is\nremoved as soon as the 'abort'
event is handled. Failure to do so may\nresult in memory leaks.
An optional callback function that may be set by user code to be notified\nwhen the abortController.abort()
function has been called.
An optional reason specified when the AbortSignal
was triggered.
const ac = new AbortController();\nac.abort(new Error('boom!'));\nconsole.log(ac.signal.reason); // Error: boom!\n
"
}
],
"methods": [
{
"textRaw": "`abortSignal.throwIfAborted()`",
"type": "method",
"name": "throwIfAborted",
"meta": {
"added": [
"v17.3.0",
"v16.17.0"
],
"changes": []
},
"signatures": [
{
"params": []
}
],
"desc": "If abortSignal.aborted
is true
, throws abortSignal.reason
.
See <Blob>.
" }, { "textRaw": "Class: `Buffer`", "type": "global", "name": "Buffer", "meta": { "added": [ "v0.1.103" ], "changes": [] }, "desc": "Used to handle binary data. See the buffer section.
" }, { "textRaw": "`clearImmediate(immediateObject)`", "type": "global", "name": "clearImmediate", "meta": { "added": [ "v0.9.1" ], "changes": [] }, "desc": "clearImmediate
is described in the timers section.
clearInterval
is described in the timers section.
clearTimeout
is described in the timers section.
Used to print to stdout and stderr. See the console
section.
A browser-compatible implementation of the CustomEvent
Web API.
A browser-compatible implementation of the Event
class. See\nEventTarget
and Event
API for more details.
A browser-compatible implementation of the EventTarget
class. See\nEventTarget
and Event
API for more details.
See <File>.
" }, { "textRaw": "`global`", "name": "`global`", "meta": { "added": [ "v0.1.27" ], "changes": [] }, "type": "global", "stability": 3, "stabilityText": "Legacy. Use [`globalThis`][] instead.", "desc": "In browsers, the top-level scope has traditionally been the global scope. This\nmeans that var something
will define a new global variable, except within\nECMAScript modules. In Node.js, this is different. The top-level scope is not\nthe global scope; var something
inside a Node.js module will be local to that\nmodule, regardless of whether it is a CommonJS module or an\nECMAScript module.
The MessageChannel
class. See MessageChannel
for more details.
The MessageEvent
class. See MessageEvent
for more details.
The MessagePort
class. See MessagePort
for more details.
The PerformanceEntry
class. See PerformanceEntry
for more details.
The PerformanceMark
class. See PerformanceMark
for more details.
The PerformanceMeasure
class. See PerformanceMeasure
for more details.
The PerformanceObserver
class. See PerformanceObserver
for more details.
The PerformanceObserverEntryList
class. See\nPerformanceObserverEntryList
for more details.
The PerformanceResourceTiming
class. See PerformanceResourceTiming
for\nmore details.
The process object. See the process
object section.
callback
<Function> Function to be queued.The queueMicrotask()
method queues a microtask to invoke callback
. If\ncallback
throws an exception, the process
object 'uncaughtException'
\nevent will be emitted.
The microtask queue is managed by V8 and may be used in a similar manner to\nthe process.nextTick()
queue, which is managed by Node.js. The\nprocess.nextTick()
queue is always processed before the microtask queue\nwithin each turn of the Node.js event loop.
// Here, `queueMicrotask()` is used to ensure the 'load' event is always\n// emitted asynchronously, and therefore consistently. Using\n// `process.nextTick()` here would result in the 'load' event always emitting\n// before any other promise jobs.\n\nDataHandler.prototype.load = async function load(key) {\n const hit = this._cache.get(key);\n if (hit !== undefined) {\n queueMicrotask(() => {\n this.emit('load', hit);\n });\n return;\n }\n\n const data = await fetchData(key);\n this._cache.set(key, data);\n this.emit('load', data);\n};\n
"
},
{
"textRaw": "`setImmediate(callback[, ...args])`",
"type": "global",
"name": "setImmediate",
"meta": {
"added": [
"v0.9.1"
],
"changes": []
},
"desc": "setImmediate
is described in the timers section.
setInterval
is described in the timers section.
setTimeout
is described in the timers section.
The WHATWG structuredClone
method.
The WHATWG DOMException
class. See DOMException
for more details.
The WHATWG TextDecoder
class. See the TextDecoder
section.
The WHATWG TextEncoder
class. See the TextEncoder
section.
The WHATWG URL
class. See the URL
section.
The WHATWG URLSearchParams
class. See the URLSearchParams
section.
The object that acts as the namespace for all W3C\nWebAssembly related functionality. See the\nMozilla Developer Network for usage and compatibility.
" } ], "classes": [ { "textRaw": "Class: `ByteLengthQueuingStrategy`", "type": "class", "name": "ByteLengthQueuingStrategy", "meta": { "added": [ "v18.0.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental.", "desc": "A browser-compatible implementation of ByteLengthQueuingStrategy
.
A browser-compatible implementation of CompressionStream
.
A browser-compatible implementation of CountQueuingStrategy
.
A browser-compatible implementation of DecompressionStream
.
A browser-compatible implementation of ReadableByteStreamController
.
A browser-compatible implementation of ReadableStream
.
A browser-compatible implementation of ReadableStreamBYOBReader
.
A browser-compatible implementation of ReadableStreamBYOBRequest
.
A browser-compatible implementation of ReadableStreamDefaultController
.
A browser-compatible implementation of ReadableStreamDefaultReader
.
A browser-compatible implementation of TextDecoderStream
.
A browser-compatible implementation of TextEncoderStream
.
A browser-compatible implementation of TransformStream
.
A browser-compatible implementation of TransformStreamDefaultController
.
A browser-compatible implementation of WritableStream
.
A browser-compatible implementation of WritableStreamDefaultController
.
A browser-compatible implementation of WritableStreamDefaultWriter
.
This variable may appear to be global but is not. See __dirname
.
This variable may appear to be global but is not. See __filename
.
See <BroadcastChannel>.
", "type": "misc", "displayName": "`BroadcastChannel`" }, { "textRaw": "`Crypto`", "name": "`crypto`", "meta": { "added": [ "v17.6.0", "v16.15.0" ], "changes": [ { "version": "v19.0.0", "pr-url": "https://github.com/nodejs/node/pull/42083", "description": "No longer behind `--experimental-global-webcrypto` CLI flag." } ] }, "stability": 1, "stabilityText": "Experimental. Disable this API with the [`--no-experimental-global-webcrypto`][] CLI flag.", "desc": "A browser-compatible implementation of <Crypto>. This global is available\nonly if the Node.js binary was compiled with including support for the\nnode:crypto
module.
A browser-compatible implementation of the Web Crypto API.
", "type": "misc", "displayName": "`crypto`" }, { "textRaw": "`CryptoKey`", "name": "`cryptokey`", "meta": { "added": [ "v17.6.0", "v16.15.0" ], "changes": [ { "version": "v19.0.0", "pr-url": "https://github.com/nodejs/node/pull/42083", "description": "No longer behind `--experimental-global-webcrypto` CLI flag." } ] }, "stability": 1, "stabilityText": "Experimental. Disable this API with the [`--no-experimental-global-webcrypto`][] CLI flag.", "desc": "A browser-compatible implementation of <CryptoKey>. This global is available\nonly if the Node.js binary was compiled with including support for the\nnode:crypto
module.
This variable may appear to be global but is not. See exports
.
A browser-compatible implementation of the fetch()
function.
A browser-compatible implementation of <FormData>.
", "type": "misc", "displayName": "Class `FormData`" }, { "textRaw": "Class `Headers`", "name": "class_`headers`", "meta": { "added": [ "v17.5.0", "v16.15.0" ], "changes": [ { "version": [ "v21.0.0" ], "pr-url": "https://github.com/nodejs/node/pull/45684", "description": "No longer experimental." }, { "version": "v18.0.0", "pr-url": "https://github.com/nodejs/node/pull/41811", "description": "No longer behind `--experimental-fetch` CLI flag." } ] }, "stability": 2, "stabilityText": "Stable", "desc": "A browser-compatible implementation of <Headers>.
", "type": "misc", "displayName": "Class `Headers`" }, { "textRaw": "`module`", "name": "`module`", "desc": "This variable may appear to be global but is not. See module
.
A partial implementation of the Navigator API.
", "type": "misc", "displayName": "`Navigator`" }, { "textRaw": "`navigator`", "name": "`navigator`", "meta": { "added": [ "v21.0.0" ], "changes": [] }, "stability": 1, "stabilityText": ".1 - Active development. Disable this API with the [`--no-experimental-global-navigator`][] CLI flag.", "desc": "A partial implementation of window.navigator
.
The navigator.hardwareConcurrency
read-only property returns the number of\nlogical processors available to the current Node.js instance.
console.log(`This process is running on ${navigator.hardwareConcurrency} logical processors`);\n
"
},
{
"textRaw": "`language` {string}",
"type": "string",
"name": "language",
"meta": {
"added": [
"v21.2.0"
],
"changes": []
},
"desc": "The navigator.language
read-only property returns a string representing the\npreferred language of the Node.js instance. The language will be determined by\nthe ICU library used by Node.js at runtime based on the\ndefault language of the operating system.
The value is representing the language version as defined in RFC 5646.
\nThe fallback value on builds without ICU is 'en-US'
.
console.log(`The preferred language of the Node.js instance has the tag '${navigator.language}'`);\n
"
},
{
"textRaw": "`languages` {ArrayThe navigator.languages
read-only property returns an array of strings\nrepresenting the preferred languages of the Node.js instance.\nBy default navigator.languages
contains only the value of\nnavigator.language
, which will be determined by the ICU library used by\nNode.js at runtime based on the default language of the operating system.
The fallback value on builds without ICU is ['en-US']
.
console.log(`The preferred languages are '${navigator.languages}'`);\n
"
},
{
"textRaw": "`platform` {string}",
"type": "string",
"name": "platform",
"meta": {
"added": [
"v21.2.0"
],
"changes": []
},
"desc": "The navigator.platform
read-only property returns a string identifying the\nplatform on which the Node.js instance is running.
console.log(`This process is running on ${navigator.platform}`);\n
"
},
{
"textRaw": "`userAgent` {string}",
"type": "string",
"name": "userAgent",
"meta": {
"added": [
"v21.1.0"
],
"changes": []
},
"desc": "The navigator.userAgent
read-only property returns user agent\nconsisting of the runtime name and major version number.
console.log(`The user-agent is ${navigator.userAgent}`); // Prints \"Node.js/21\"\n
"
}
],
"type": "misc",
"displayName": "`navigator`"
},
{
"textRaw": "`performance`",
"name": "`performance`",
"meta": {
"added": [
"v16.0.0"
],
"changes": []
},
"desc": "The perf_hooks.performance
object.
A browser-compatible implementation of <Response>.
", "type": "misc", "displayName": "`Response`" }, { "textRaw": "`Request`", "name": "`request`", "meta": { "added": [ "v17.5.0", "v16.15.0" ], "changes": [ { "version": [ "v21.0.0" ], "pr-url": "https://github.com/nodejs/node/pull/45684", "description": "No longer experimental." }, { "version": "v18.0.0", "pr-url": "https://github.com/nodejs/node/pull/41811", "description": "No longer behind `--experimental-fetch` CLI flag." } ] }, "stability": 2, "stabilityText": "Stable", "desc": "A browser-compatible implementation of <Request>.
", "type": "misc", "displayName": "`Request`" }, { "textRaw": "`SubtleCrypto`", "name": "`subtlecrypto`", "meta": { "added": [ "v17.6.0", "v16.15.0" ], "changes": [ { "version": "v19.0.0", "pr-url": "https://github.com/nodejs/node/pull/42083", "description": "No longer behind `--experimental-global-webcrypto` CLI flag." } ] }, "stability": 1, "stabilityText": "Experimental. Disable this API with the [`--no-experimental-global-webcrypto`][] CLI flag.", "desc": "A browser-compatible implementation of <SubtleCrypto>. This global is available\nonly if the Node.js binary was compiled with including support for the\nnode:crypto
module.
A browser-compatible implementation of WebSocket
. Enable this API\nwith the --experimental-websocket
CLI flag.
Global alias for buffer.atob()
.
Global alias for buffer.btoa()
.
This variable may appear to be global but is not. See require()
.