Node.js v26.8.2 documentation
- Node.js v26.8.2
- Table of contents
- Global objects
__dirname__filename- Class:
AbortController - Class:
AbortSignal atob(data)- Class:
Blob - Class:
BroadcastChannel btoa(data)- Class:
Buffer - Class:
ByteLengthQueuingStrategy clearImmediate(immediateObject)clearInterval(intervalObject)clearTimeout(timeoutObject)- Class:
CloseEvent - Class:
CompressionStream console- Class:
CountQueuingStrategy - Class:
Crypto crypto- Class:
CryptoKey - Class:
CustomEvent - Class:
DecompressionStream - Class:
DOMException ErrorEvent- Class:
Event - Class:
EventSource - Class:
EventTarget exportsfetch- Class:
File - Class:
FormData global- Class:
Headers localStorage- Class:
MessageChannel - Class:
MessageEvent - Class:
MessagePort module- Class:
Navigator navigatorperformance- Class:
PerformanceEntry - Class:
PerformanceMark - Class:
PerformanceMeasure - Class:
PerformanceObserver - Class:
PerformanceObserverEntryList - Class:
PerformanceResourceTiming processqueueMicrotask(callback)- Class:
QuotaExceededError - Class:
ReadableByteStreamController - Class:
ReadableStream - Class:
ReadableStreamBYOBReader - Class:
ReadableStreamBYOBRequest - Class:
ReadableStreamDefaultController - Class:
ReadableStreamDefaultReader - Class:
Request require()- Class:
Response sessionStoragesetImmediate(callback[, ...args])setInterval(callback, delay[, ...args])setTimeout(callback, delay[, ...args])- Class:
Storage structuredClone(value[, options])- Class:
SubtleCrypto - Class:
TextDecoder - Class:
TextDecoderStream - Class:
TextEncoder - Class:
TextEncoderStream - Class:
TransformStream - Class:
TransformStreamDefaultController - Class:
URL - Class:
URLPattern - Class:
URLSearchParams - Class:
WebAssembly - Class:
WebSocket - Class:
WritableStream - Class:
WritableStreamDefaultController - Class:
WritableStreamDefaultWriter
- Global objects
- Index
- About this documentation
- Usage and example
- Assertion testing
- Asynchronous context tracking
- Async hooks
- Buffer
- C++ addons
- C/C++ addons with Node-API
- C++ embedder API
- Child processes
- Cluster
- Command-line options
- Console
- Crypto
- Debugger
- Deprecated APIs
- Diagnostics Channel
- DNS
- Domain
- Environment Variables
- Errors
- Events
- File system
- FFI
- Globals
- HTTP
- HTTP/2
- HTTPS
- Inspector
- Internationalization
- Iterable Streams API
- Modules: CommonJS modules
- Modules: ECMAScript modules
- Modules:
node:moduleAPI - Modules: Packages
- Modules: TypeScript
- Net
- OS
- Path
- Performance hooks
- Permissions
- Process
- Punycode
- Query strings
- Readline
- REPL
- Report
- Single executable applications
- SQLite
- Stream
- String decoder
- Test runner
- Timers
- TLS/SSL
- Trace events
- TTY
- UDP/datagram
- URL
- Utilities
- V8
- Virtual File System
- VM
- WASI
- Web Crypto API
- Web Streams API
- Worker threads
- Zlib
- Other versions
- Options
Global objects#
Stability: 2 - Stable
These objects are available in all modules.
The following variables may appear to be global but are not. They exist only in the scope of CommonJS modules:
The objects listed here are specific to Node.js. There are built-in objects that are part of the JavaScript language itself, which are also globally accessible.
__dirname#
This variable may appear to be global but is not. See __dirname.
__filename#
This variable may appear to be global but is not. See __filename.
Class: AbortController#
A utility class used to signal cancelation in selected Promise-based APIs.
The API is based on the Web API <AbortController>.
const ac = new AbortController();
ac.signal.addEventListener('abort', () => console.log('Aborted!'),
{ once: true });
ac.abort();
console.log(ac.signal.aborted); // Prints true
abortController.abort([reason])#
reason<any>An optional reason, retrievable on theAbortSignal'sreasonproperty.
Triggers the abort signal, causing the abortController.signal to emit
the 'abort' event.
abortController.signal#
- Type:
<AbortSignal>
Class: AbortSignal#
- Extends:
<EventTarget>
The AbortSignal is used to notify observers when the
abortController.abort() method is called.
Static method: AbortSignal.abort([reason])#
reason<any>- Returns:
<AbortSignal>
Returns a new already aborted AbortSignal.
Static method: AbortSignal.timeout(delay)#
delay<number>The number of milliseconds to wait before triggering the AbortSignal.
Returns a new AbortSignal which will be aborted in delay milliseconds.
Static method: AbortSignal.any(signals)#
signals<AbortSignal>[] TheAbortSignals of which to compose a newAbortSignal.
Returns a new AbortSignal which will be aborted if any of the provided
signals are aborted. Its abortSignal.reason will be set to whichever
one of the signals caused it to be aborted.
Event: 'abort'#
The 'abort' event is emitted when the abortController.abort() method
is called. The callback is invoked with a single object argument with a
single type property set to 'abort':
const ac = new AbortController();
// Use either the onabort property...
ac.signal.onabort = () => console.log('aborted!');
// Or the EventTarget API...
ac.signal.addEventListener('abort', (event) => {
console.log(event.type); // Prints 'abort'
}, { once: true });
ac.abort();
The AbortController with which the AbortSignal is associated will only
ever trigger the 'abort' event once. We recommended that code check
that the abortSignal.aborted attribute is false before adding an 'abort'
event listener.
Any event listeners attached to the AbortSignal should use the
{ once: true } option (or, if using the EventEmitter APIs to attach a
listener, use the once() method) to ensure that the event listener is
removed as soon as the 'abort' event is handled. Failure to do so may
result in memory leaks.
abortSignal.aborted#
- Type:
<boolean>
True after the AbortController has been aborted.
abortSignal.onabort#
- Type:
<Function>
An optional callback function that may be set by user code to be notified
when the abortController.abort() function has been called.
abortSignal.reason#
- Type:
<any>