Node.js Complete Reference Index
Select any item below to open its full syntax specification, parameters, and live example.
Globals
AbortController.abort()controller.abort([reason])
Signals cancellation to consumers of controller.signal. Consumers must support cancellation; completed side effects are not reversed.
AbortSignal.abort()AbortSignal.abort([reason])
Creates a signal that is already aborted. Use it when an operation should not start, including tests for early cancellation. A signal is single-use; an aborted signal does not reset to active. Tested on Node.js 22.16.0. Example output (one line per entry): ["true closed"].
AbortSignal.any()AbortSignal.any(signals)
Combines several cancellation sources. The resulting signal aborts when one input aborts, with that input reason; if an input is already aborted it can settle immediately. Use separate signals for separate operation lifetimes. Tested on Node.js 22.16.0. Example output (one line per entry): ["true shutdown"].
AbortSignal.timeout()AbortSignal.timeout(delay)
Creates a signal that aborts after a delay. Supply it to operations that honor signals; creating a signal alone cannot stop arbitrary synchronous JavaScript. The test uses an independent referenced timer only to keep the process alive. Tested on Node.js 22.16.0. Example output (one line per entry): ["TimeoutError"].
Architecture
Observability
Async context
AsyncLocalStorage.bind()AsyncLocalStorage.bind(fn)
Returns a function bound to the execution context at binding time. Useful when handing a callback to a scheduler that otherwise executes it outside the desired scope. Release references when the callback is no longer needed. Tested on Node.js 22.16.0. Example output (one line per entry): ["saved"].
AsyncLocalStorage.snapshot()
Captures the current execution context and returns a function that invokes another function in that captured context. Use it for controlled callback handoff, not to carry a stale request context into unrelated work. Tested on Node.js 22.16.0. Example output (one line per entry): ["captured current"].
MongoDB
Security
Authorization policydecide(principal, action) → status (lesson-defined policy)
Authentication establishes who is making a request. Authorization decides whether that identity may perform a particular action. A signed-in reader can be allowed to view the catalog while being forbidden to change its prices. Always make the permission decision on the server, using an identity established by trusted authentication middleware. Never accept a role or user ID from a request body as proof of identity. An authenticated user is not automatically an administrator. A hidden button is not a server-side permission check. Evidence: local teaching fixture, not a production security guarantee. Source: https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html
Browser security boundariescors(origin) → response headers (lesson-defined policy)
CORS governs whether a browser allows scripts from another origin to access a response. CSRF protection addresses unwanted actions made through a browser carrying a user’s credentials. They solve different problems, and neither replaces server-side permission checks. Do not treat an omitted CORS header as denial of a server-side action. Non-browser clients do not enforce browser CORS. Do not reflect arbitrary Origin values or treat HttpOnly as a CSRF prevention mechanism. Evidence: local teaching fixture, not a production security guarantee. Source: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html
Runtime
Buffer
Buffer base64url encodingBuffer.from(text, 'base64url'); bytes.toString('base64url')
Encodes bytes using the URL-safe Base64 alphabet without output padding. This is reversible encoding, not secrecy or integrity. Tested on Node.js 22.16.0. Example output (one line per entry): ["-_8 true"].
Buffer.alloc()Buffer.alloc(size[, fill[, encoding]])
Creates initialized byte storage; the default contents are zero. Tested on Node.js 22.16.0. Keep allocation sizes bounded; prefer initialized storage over allocUnsafe for beginner code.
Buffer.byteLength()Buffer.byteLength(string[, encoding])
Counts bytes required by an encoding rather than JavaScript UTF-16 code units. Tested on Node.js 22.16.0. For malformed hex or base64 text the count need not match decoding; validate input separately.
Buffer.concat()Buffer.concat(list[, totalLength])
Combines byte arrays into new storage in the supplied order. Tested on Node.js 22.16.0. A supplied length can truncate or zero-pad; avoid concatenating unbounded request bodies.
Buffer.copy()source.copy(target[, targetStart[, sourceStart[, sourceEnd]]])
Copies bytes into a destination buffer. Unlike subarray, the destination does not share the copied region when separately allocated. Tested on Node.js 22.16.0. Example output (one line per entry): ["2 oo", "book"].
Buffer.equals()buf.equals(otherBuffer)
Checks whether two byte sequences have identical contents. Tested on Node.js 22.16.0. Do not use ordinary equality comparison as a constant-time cryptographic verification primitive.
Buffer.from(string)Buffer.from(string[, encoding])
Encodes a string into a Buffer. UTF-8 is the default. Other overloads accept arrays, buffers and ArrayBuffers with different copy/sharing semantics.
Buffer.isBuffer()Buffer.isBuffer(obj)
Distinguishes Node Buffer instances from ordinary typed arrays and other values. Tested on Node.js 22.16.0. Use it only when the Buffer-specific interface matters; Uint8Array is also valid for many APIs.
Showing 20 of 490 entries