{ "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" ], "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.

\n
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()`", "type": "method", "name": "abort", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "signatures": [ { "params": [] } ], "desc": "

Triggers the abort signal, causing the abortController.signal to emit\nthe 'abort' event.

" } ], "properties": [ { "textRaw": "`signal` Type: {AbortSignal}", "type": "AbortSignal", "name": "Type", "meta": { "added": [ "v15.0.0" ], "changes": [] } } ], "classes": [ { "textRaw": "Class: `AbortSignal`", "type": "class", "name": "AbortSignal", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "\n

The AbortSignal is used to notify observers when the\nabortController.abort() method is called.

", "classMethods": [ { "textRaw": "Static method: `AbortSignal.abort()`", "type": "classMethod", "name": "abort", "meta": { "added": [ "v15.12.0" ], "changes": [] }, "signatures": [ { "return": { "textRaw": "Returns: {AbortSignal}", "name": "return", "type": "AbortSignal" }, "params": [] } ], "desc": "

Returns a new already aborted AbortSignal.

" } ], "events": [ { "textRaw": "Event: `'abort'`", "type": "event", "name": "abort", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "params": [], "desc": "

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':

\n
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
\n

The 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.

\n

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.

" } ], "properties": [ { "textRaw": "`aborted` Type: {boolean} True after the `AbortController` has been aborted.", "type": "boolean", "name": "Type", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "True after the `AbortController` has been aborted." }, { "textRaw": "`onabort` Type: {Function}", "type": "Function", "name": "Type", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

An optional callback function that may be set by user code to be notified\nwhen the abortController.abort() function has been called.

" } ] } ] }, { "textRaw": "Class: `Buffer`", "type": "global", "name": "Buffer", "meta": { "added": [ "v0.1.103" ], "changes": [] }, "desc": "\n

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.

" }, { "textRaw": "`clearInterval(intervalObject)`", "type": "global", "name": "clearInterval", "meta": { "added": [ "v0.0.1" ], "changes": [] }, "desc": "

clearInterval is described in the timers section.

" }, { "textRaw": "`clearTimeout(timeoutObject)`", "type": "global", "name": "clearTimeout", "meta": { "added": [ "v0.0.1" ], "changes": [] }, "desc": "

clearTimeout is described in the timers section.

" }, { "textRaw": "`console`", "name": "`console`", "meta": { "added": [ "v0.1.100" ], "changes": [] }, "type": "global", "desc": "\n

Used to print to stdout and stderr. See the console section.

" }, { "textRaw": "`Event`", "name": "`Event`", "meta": { "added": [ "v15.0.0" ], "changes": [ { "version": "v15.4.0", "pr-url": "https://github.com/nodejs/node/pull/35949", "description": "No longer experimental." } ] }, "type": "global", "desc": "

A browser-compatible implementation of the Event class. See\nEventTarget and Event API for more details.

" }, { "textRaw": "`EventTarget`", "name": "`EventTarget`", "meta": { "added": [ "v15.0.0" ], "changes": [ { "version": "v15.4.0", "pr-url": "https://github.com/nodejs/node/pull/35949", "description": "No longer experimental." } ] }, "type": "global", "desc": "

A browser-compatible implementation of the EventTarget class. See\nEventTarget and Event API for more details.

" }, { "textRaw": "`global`", "name": "`global`", "meta": { "added": [ "v0.1.27" ], "changes": [] }, "type": "global", "desc": "\n

In browsers, the top-level scope is the global scope. This means that\nwithin the browser var something will define a new global variable. In\nNode.js this is different. The top-level scope is not the global scope;\nvar something inside a Node.js module will be local to that module.

" }, { "textRaw": "`MessageChannel`", "name": "`MessageChannel`", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "type": "global", "desc": "

The MessageChannel class. See MessageChannel for more details.

" }, { "textRaw": "`MessageEvent`", "name": "`MessageEvent`", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "type": "global", "desc": "

The MessageEvent class. See MessageEvent for more details.

" }, { "textRaw": "`MessagePort`", "name": "`MessagePort`", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "type": "global", "desc": "

The MessagePort class. See MessagePort for more details.

" }, { "textRaw": "`process`", "name": "`process`", "meta": { "added": [ "v0.1.7" ], "changes": [] }, "type": "global", "desc": "\n

The process object. See the process object section.

" }, { "textRaw": "`queueMicrotask(callback)`", "type": "global", "name": "queueMicrotask", "meta": { "added": [ "v11.0.0" ], "changes": [] }, "desc": "\n

The queueMicrotask() method queues a microtask to invoke callback. If\ncallback throws an exception, the process object 'uncaughtException'\nevent will be emitted.

\n

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.

\n
// 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(url);\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(url, 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.

" }, { "textRaw": "`setInterval(callback, delay[, ...args])`", "type": "global", "name": "setInterval", "meta": { "added": [ "v0.0.1" ], "changes": [] }, "desc": "

setInterval is described in the timers section.

" }, { "textRaw": "`setTimeout(callback, delay[, ...args])`", "type": "global", "name": "setTimeout", "meta": { "added": [ "v0.0.1" ], "changes": [] }, "desc": "

setTimeout is described in the timers section.

" }, { "textRaw": "`TextDecoder`", "name": "`TextDecoder`", "meta": { "added": [ "v11.0.0" ], "changes": [] }, "type": "global", "desc": "

The WHATWG TextDecoder class. See the TextDecoder section.

" }, { "textRaw": "`TextEncoder`", "name": "`TextEncoder`", "meta": { "added": [ "v11.0.0" ], "changes": [] }, "type": "global", "desc": "

The WHATWG TextEncoder class. See the TextEncoder section.

" }, { "textRaw": "`URL`", "name": "`URL`", "meta": { "added": [ "v10.0.0" ], "changes": [] }, "type": "global", "desc": "

The WHATWG URL class. See the URL section.

" }, { "textRaw": "`URLSearchParams`", "name": "`URLSearchParams`", "meta": { "added": [ "v10.0.0" ], "changes": [] }, "type": "global", "desc": "

The WHATWG URLSearchParams class. See the URLSearchParams section.

" }, { "textRaw": "`WebAssembly`", "name": "`WebAssembly`", "meta": { "added": [ "v8.0.0" ], "changes": [] }, "type": "global", "desc": "\n

The object that acts as the namespace for all W3C\nWebAssembly related functionality. See the\nMozilla Developer Network for usage and compatibility.

" } ], "methods": [ { "textRaw": "`atob(data)`", "type": "method", "name": "atob", "meta": { "added": [ "v16.0.0" ], "changes": [] }, "stability": 3, "stabilityText": "Legacy. Use `Buffer.from(data, 'base64')` instead.", "signatures": [ { "params": [] } ], "desc": "

Global alias for buffer.atob().

" }, { "textRaw": "`btoa(data)`", "type": "method", "name": "btoa", "meta": { "added": [ "v16.0.0" ], "changes": [] }, "stability": 3, "stabilityText": "Legacy. Use `buf.toString('base64')` instead.", "signatures": [ { "params": [] } ], "desc": "

Global alias for buffer.btoa().

" }, { "textRaw": "`require()`", "type": "method", "name": "require", "signatures": [ { "params": [] } ], "desc": "

This variable may appear to be global but is not. See require().

" } ], "miscs": [ { "textRaw": "Global objects", "name": "Global objects", "introduced_in": "v0.10.0", "type": "misc", "desc": "

These objects are available in all modules. The following variables may appear\nto be global but are not. They exist only in the scope of modules, see the\nmodule system documentation:

\n\n

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" ], "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.

\n
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()`", "type": "method", "name": "abort", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "signatures": [ { "params": [] } ], "desc": "

Triggers the abort signal, causing the abortController.signal to emit\nthe 'abort' event.

" } ], "properties": [ { "textRaw": "`signal` Type: {AbortSignal}", "type": "AbortSignal", "name": "Type", "meta": { "added": [ "v15.0.0" ], "changes": [] } } ], "classes": [ { "textRaw": "Class: `AbortSignal`", "type": "class", "name": "AbortSignal", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "\n

The AbortSignal is used to notify observers when the\nabortController.abort() method is called.

", "classMethods": [ { "textRaw": "Static method: `AbortSignal.abort()`", "type": "classMethod", "name": "abort", "meta": { "added": [ "v15.12.0" ], "changes": [] }, "signatures": [ { "return": { "textRaw": "Returns: {AbortSignal}", "name": "return", "type": "AbortSignal" }, "params": [] } ], "desc": "

Returns a new already aborted AbortSignal.

" } ], "events": [ { "textRaw": "Event: `'abort'`", "type": "event", "name": "abort", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "params": [], "desc": "

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':

\n
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
\n

The 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.

\n

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.

" } ], "properties": [ { "textRaw": "`aborted` Type: {boolean} True after the `AbortController` has been aborted.", "type": "boolean", "name": "Type", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "True after the `AbortController` has been aborted." }, { "textRaw": "`onabort` Type: {Function}", "type": "Function", "name": "Type", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

An optional callback function that may be set by user code to be notified\nwhen the abortController.abort() function has been called.

" } ] } ] }, { "textRaw": "Class: `Buffer`", "type": "global", "name": "Buffer", "meta": { "added": [ "v0.1.103" ], "changes": [] }, "desc": "\n

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.

" }, { "textRaw": "`clearInterval(intervalObject)`", "type": "global", "name": "clearInterval", "meta": { "added": [ "v0.0.1" ], "changes": [] }, "desc": "

clearInterval is described in the timers section.

" }, { "textRaw": "`clearTimeout(timeoutObject)`", "type": "global", "name": "clearTimeout", "meta": { "added": [ "v0.0.1" ], "changes": [] }, "desc": "

clearTimeout is described in the timers section.

" }, { "textRaw": "`console`", "name": "`console`", "meta": { "added": [ "v0.1.100" ], "changes": [] }, "type": "global", "desc": "\n

Used to print to stdout and stderr. See the console section.

" }, { "textRaw": "`Event`", "name": "`Event`", "meta": { "added": [ "v15.0.0" ], "changes": [ { "version": "v15.4.0", "pr-url": "https://github.com/nodejs/node/pull/35949", "description": "No longer experimental." } ] }, "type": "global", "desc": "

A browser-compatible implementation of the Event class. See\nEventTarget and Event API for more details.

" }, { "textRaw": "`EventTarget`", "name": "`EventTarget`", "meta": { "added": [ "v15.0.0" ], "changes": [ { "version": "v15.4.0", "pr-url": "https://github.com/nodejs/node/pull/35949", "description": "No longer experimental." } ] }, "type": "global", "desc": "

A browser-compatible implementation of the EventTarget class. See\nEventTarget and Event API for more details.

" }, { "textRaw": "`global`", "name": "`global`", "meta": { "added": [ "v0.1.27" ], "changes": [] }, "type": "global", "desc": "\n

In browsers, the top-level scope is the global scope. This means that\nwithin the browser var something will define a new global variable. In\nNode.js this is different. The top-level scope is not the global scope;\nvar something inside a Node.js module will be local to that module.

" }, { "textRaw": "`MessageChannel`", "name": "`MessageChannel`", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "type": "global", "desc": "

The MessageChannel class. See MessageChannel for more details.

" }, { "textRaw": "`MessageEvent`", "name": "`MessageEvent`", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "type": "global", "desc": "

The MessageEvent class. See MessageEvent for more details.

" }, { "textRaw": "`MessagePort`", "name": "`MessagePort`", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "type": "global", "desc": "

The MessagePort class. See MessagePort for more details.

" }, { "textRaw": "`process`", "name": "`process`", "meta": { "added": [ "v0.1.7" ], "changes": [] }, "type": "global", "desc": "\n

The process object. See the process object section.

" }, { "textRaw": "`queueMicrotask(callback)`", "type": "global", "name": "queueMicrotask", "meta": { "added": [ "v11.0.0" ], "changes": [] }, "desc": "\n

The queueMicrotask() method queues a microtask to invoke callback. If\ncallback throws an exception, the process object 'uncaughtException'\nevent will be emitted.

\n

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.

\n
// 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(url);\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(url, 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.

" }, { "textRaw": "`setInterval(callback, delay[, ...args])`", "type": "global", "name": "setInterval", "meta": { "added": [ "v0.0.1" ], "changes": [] }, "desc": "

setInterval is described in the timers section.

" }, { "textRaw": "`setTimeout(callback, delay[, ...args])`", "type": "global", "name": "setTimeout", "meta": { "added": [ "v0.0.1" ], "changes": [] }, "desc": "

setTimeout is described in the timers section.

" }, { "textRaw": "`TextDecoder`", "name": "`TextDecoder`", "meta": { "added": [ "v11.0.0" ], "changes": [] }, "type": "global", "desc": "

The WHATWG TextDecoder class. See the TextDecoder section.

" }, { "textRaw": "`TextEncoder`", "name": "`TextEncoder`", "meta": { "added": [ "v11.0.0" ], "changes": [] }, "type": "global", "desc": "

The WHATWG TextEncoder class. See the TextEncoder section.

" }, { "textRaw": "`URL`", "name": "`URL`", "meta": { "added": [ "v10.0.0" ], "changes": [] }, "type": "global", "desc": "

The WHATWG URL class. See the URL section.

" }, { "textRaw": "`URLSearchParams`", "name": "`URLSearchParams`", "meta": { "added": [ "v10.0.0" ], "changes": [] }, "type": "global", "desc": "

The WHATWG URLSearchParams class. See the URLSearchParams section.

" }, { "textRaw": "`WebAssembly`", "name": "`WebAssembly`", "meta": { "added": [ "v8.0.0" ], "changes": [] }, "type": "global", "desc": "\n

The object that acts as the namespace for all W3C\nWebAssembly related functionality. See the\nMozilla Developer Network for usage and compatibility.

" } ], "miscs": [ { "textRaw": "`__dirname`", "name": "`__dirname`", "desc": "

This variable may appear to be global but is not. See __dirname.

", "type": "misc", "displayName": "`__dirname`" }, { "textRaw": "`__filename`", "name": "`__filename`", "desc": "

This variable may appear to be global but is not. See __filename.

", "type": "misc", "displayName": "`__filename`" }, { "textRaw": "`exports`", "name": "`exports`", "desc": "

This variable may appear to be global but is not. See exports.

", "type": "misc", "displayName": "`exports`" }, { "textRaw": "`module`", "name": "`module`", "desc": "

This variable may appear to be global but is not. See module.

", "type": "misc", "displayName": "`module`" }, { "textRaw": "`performance`", "name": "`performance`", "desc": "

The perf_hooks.performance object.

", "type": "misc", "displayName": "`performance`" } ], "methods": [ { "textRaw": "`atob(data)`", "type": "method", "name": "atob", "meta": { "added": [ "v16.0.0" ], "changes": [] }, "stability": 3, "stabilityText": "Legacy. Use `Buffer.from(data, 'base64')` instead.", "signatures": [ { "params": [] } ], "desc": "

Global alias for buffer.atob().

" }, { "textRaw": "`btoa(data)`", "type": "method", "name": "btoa", "meta": { "added": [ "v16.0.0" ], "changes": [] }, "stability": 3, "stabilityText": "Legacy. Use `buf.toString('base64')` instead.", "signatures": [ { "params": [] } ], "desc": "

Global alias for buffer.btoa().

" }, { "textRaw": "`require()`", "type": "method", "name": "require", "signatures": [ { "params": [] } ], "desc": "

This variable may appear to be global but is not. See require().

" } ] } ] }