Skip to main content

Module stdlib

Module stdlib 

Source
Expand description

Node.js core modules implemented natively for node-js.

A require(spec) (see builtins::call_builtin_function) resolves a supported module to a JsObj::Builtin("<module>") namespace value — exactly the shape of the built-in console/Math namespaces — so mod.method(...) dispatches through host::call_method → builtins::call_builtin_function("<module>.<method>") → stdlib::call, and const { method } = require('mod') reads the method as a first-class Builtin("mod.method") via namespace_property.

Every stdlib function is free-standing and acquires the thread-local JsHost through with_host only around allocations (and releases it before any re-entrant host::invoke), so callbacks (fs async, EventEmitter.emit, assert.throws) never double-borrow the host. Stateful instances (Buffer, crypto Hash, EventEmitter, URL) are plain objects carrying a hidden @@native tag (filtered from enumeration/display like @@iterator); their methods route through instance_call from host::call_method.

Modules§

assert
Node assert module. Failing assertions throw an AssertionError (returned as an Err, which the host surfaces as a thrown JS exception).
assert_diff
The structural diff Node prints inside an AssertionError message.
async_hooks
Node async_hooks module — honest minimal implementation.
buffer
Node Buffer (global + require('buffer').Buffer). A Buffer is a plain object tagged @@native = "Buffer" whose bytes live in a hidden @@bytes array SHARED with its ArrayBuffer (@@buffer, read as buf.buffer); the Buffer is a window (byteOffset/length) onto it, so every reader goes through window_bytes_h.
child_process
Node child_process module — real subprocess execution via std::process::Command.
cluster
Node cluster — real process-fork model over std::process::Command.
console
Node console module (require('console')), sharing the exact rendering the global console.* uses: every argument is run through JsHost::console_format (strings verbatim, everything else via util.inspect) and space-joined — the same pipeline builtins::print_line drives — so module output is identical to the global. log/info/debug go to stdout; error/warn/trace/assert to stderr. count, group and time keep per-thread state here (a monotonic Instant backs the timers, so timeEnd reports a real elapsed duration).
constants
The platform’s errno, signal and filesystem constants.
crypto
Node crypto module.
date
JavaScript Date (global constructor). A Date is a plain object tagged @@native = "Date" whose time value (milliseconds since the Unix epoch, or NaN for an invalid date) lives in a hidden @@ms field.
dgram
Node dgram module: real UDP sockets over std::net::UdpSocket.
diagnostics_channel
Node diagnostics_channel — in-process publish/subscribe named channels.
dns
Node dns module.
domain
Node domain module (deprecated in Node, implemented here with its real error-trapping semantics). A Domain is an EventEmitter (same @@native + @@on/@@once shape as events/net) whose defining behaviour is domain.run(fn): it runs fn and, if fn throws, emits the domain’s 'error' event with the thrown value instead of propagating the throw.
event_target
The WHATWG Event / EventTarget / CustomEvent globals — a port of node’s lib/internal/event_target.js, restricted to what a non-DOM target can observe (there is no tree, so there is no capture or bubble PATH: every dispatch runs at the target, eventPhase is AT_TARGET while listeners run and composedPath() is [target]).
events
Node events module: EventEmitter. The emitter is an object tagged @@native = "EventEmitter" with a hidden @@on map (event name → the ordered RAW listener array: a once registration is stored as node’s _onceWrap wrapper, whose .listener is the function registered). emit collects listeners, releases the host borrow, then invokes each so callbacks can re-enter the host.
fetch
The WHATWG Fetch globals: fetch, Headers, Request, Response, Blob, FormData, AbortController and AbortSignal.
fs
Node fs module: synchronous file operations, the async callback forms, and the file-descriptor / directory / stream / watcher surfaces.
fs_promises
Node fs/promises (also require('fs').promises) — Promise-returning file operations.
http
Node http module: an HTTP/1.1 server built on top of net.
http2
Node http2 module: a REAL, minimal HTTP/2 server over TLS+ALPN.
https
Node https module: HTTP/1.1 over real TLS.
iterator
Iterator helpers (27.1.4) — map, filter, take, drop, flatMap and the terminal reduce/toArray/forEach/some/every/find, plus the Iterator constructor, Iterator.from and Iterator.concat.
net
Node net module: TCP Server and Socket.
node_module
Node module core module — require('module') (a.k.a. require('node:module')).
os
Node os module. Values that Node derives from the host (platform, arch, hostname, home/tmp dirs, endianness, EOL) are returned faithfully; the machine-specific numeric readings (cpus, totalmem, freemem, loadavg, uptime) return best-effort placeholders (not fuzzed — they vary per host on reference Node too).
path
Node path module — both flavors.
perf_hooks
Node perf_hooks module.
process
Node process global — the subset packages read at load time.
punycode
Node punycode module — a faithful implementation of the RFC 3492 Bootstring algorithm with the Punycode parameter set. The module is deprecated in Node but still present; the codec is pure and deterministic (no host state beyond allocating the returned string/array), so it round-trips independently of any network or locale.
querystring
Node querystring module, a port of lib/querystring.js: parse/stringify (and their decode/encode aliases, which are the same functions), escape, unescape and unescapeBuffer. The legacy application/x-www-form-urlencoded rules, with + standing for a space — distinct from the qs package express also ships.
readline
Node readline module.
repl
Node repl module — repl.start([options]).
stream
Node stream module: native base classes + module helper functions.
stream_consumers
Node stream/consumers module: read an entire stream to a single value.
stream_promises
Node stream/promises module: the Promise-based finished and pipeline.
stream_web
Node stream/web module: the WHATWG Streams API.
string_decoder
Node string_decoder core module: new StringDecoder(encoding) with .write(buffer) / .end([buffer]). A StringDecoder turns byte chunks into a string, holding back an incomplete trailing multibyte sequence until the next chunk completes it.
timers
Node timers and timers/promises modules.
tls
Node tls module: real TLS over blocking rustls (rustls::StreamOwned wrapping a std::net::TcpStream).
trace_events
Node trace_events module.
tty
Node tty module.
typedarray
JavaScript typed arrays (Uint8Array/Int8Array/…/Float64Array), ArrayBuffer, WeakRef, and TextEncoder/TextDecoder.
url
Node url module: the WHATWG URL class (global + require('url').URL) and the legacy url.parse. Parsing and the component setters are the URL Standard’s, through the url crate (its basic URL parser and quirks setters). A URL instance keeps each component in a hidden @@<name> slot read by the accessors on URL.prototype; a setter rewrites every slot from the re-serialized URL (set_component), and the searchParams it carries holds an @@ownerUrl back-reference so its own mutations rewrite the query in the other direction.
url_legacy
The legacy url.parse / url.format API — a faithful port of Node’s lib/url.js Url.prototype.parse, Url.prototype.format and urlFormat.
util
Node util module: format, inspect, and a subset of util.types.
util_types
Node util.types — runtime type-tag predicates.
v8
Node v8 module — a compatibility shim, NOT real V8 introspection.
vm
Node vm module — code compilation and evaluation reusing node-js’s own engine.
worker_threads
Node worker_threads: real OS-thread workers with fully isolated heaps.
zlib
Node zlib module — real DEFLATE / zlib / gzip / brotli / zstd + CRC-32.

Constants§

SUBTLE_CRYPTO_CLASS
The key of the SubtleCrypto CLASS. SubtleCrypto itself names the crypto.subtle namespace, and the last dotted segment is the name the class reports.
UNIMPLEMENTED_MODULES
Native-heavy core modules that node-js does not yet implement (TLS handshakes, HTTP/2 framing, OS worker threads sharing the thread-local heap, UDP sockets, V8 inspector, etc.). requireing them succeeds and yields a namespace so that programs which import-then-conditionally-use them still load; ACTUALLY calling a method throws Error: <mod>.<method> is not implemented in node-js. This is an honest not-yet-built surface, never a silent fake.

Functions§

brand_checked_class
The web classes whose prototype getters brand-check this and throw ERR_INVALID_THIS for any other receiver.
call
Dispatch a resolved stdlib builtin (assert, or namespace.method). Returns None if name is not a stdlib builtin (the caller falls through to the core builtin table).
class_display_name
The display name of a class key (webcrypto.SubtleCrypto → SubtleCrypto).
constant
A non-function constant on a stdlib namespace (path.sep, os.EOL, buffer.Buffer, url.URL), reachable via namespace_property.
construct
Construct a stdlib class instance (new URL(...), new EventEmitter(), and new Buffer(...) legacy), reachable from construct_builtin. None if name is not a stdlib constructor.
core_keys
node’s Object.keys(require(id)) for the core module spelled ns.
data_module
Canonical namespace name a require(spec) resolves to (after stripping an optional node: prefix), or None for an unsupported module. Core modules whose export is a plain DATA value rather than a namespace of methods. require('constants') is the only one: every member is a number, so it is built as a real object instead of a Builtin handle, whose members are dispatchable methods by construction.
has_to_json
Native instance tags whose instance_call implements toJSON(), which JSON.stringify must invoke before serializing the value. (instance_has_method only covers tags with a declared method table; Date dispatches directly.)
illegal_constructor
new Performance(), new Crypto(), … — classes node lets no script build.
instance_accessor_written
instance_accessors
instance_call
Dispatch a method call on a native stdlib instance (recv carries a @@native tag). Called from host::call_method before the generic object method resolution.
instance_has_method
Whether name is a method of a native instance tagged tag. Used by get_property so a method read (server.listen.apply(...), the express listen path) yields a bound method rather than undefined — the method is still dispatched through instance_call when the bound method is invoked.
instance_inspect_is_custom
Whether node gives instances of tag a CUSTOM util.inspect — one that prints a curated view and nothing else. Such a class hides a subclass’s own properties and the [Tag] suffix: class S extends AbortController {} is S { signal: … }, and an EventTarget subclass prints {} even with own fields.
instance_inspect_members
How util.inspect renders an instance of tag, as (accessors to show, whether to print the class name).
instance_late_methods
The ACCESSOR properties a native class’s prototype carries, as (name, has_setter), and the Symbol.toStringTag it stamps (empty for none).
instance_members_enumerable
instance_method_lists
is_core
Whether spec names a core module of any kind — a method namespace or a data module. This is what require.resolve answers with the bare specifier.
is_method
True if qualified (namespace.method) is a stdlib method that call_builtin_function should route into call (extends is_known_builtin).
is_unimplemented
True if ns is a known-but-unimplemented core module (see UNIMPLEMENTED_MODULES).
namespace_ctors
Class/constructor members a namespace re-exports as values rather than callable methods (require('buffer').Buffer, require('url').URL). They are enumerable own keys too, so for (k in buffer) sees Buffer.
namespace_keys
namespace_methods
The callable members of builtin namespace ns. THE single table backing both is_method (does ns.m dispatch?) and namespace_keys (what does for (k in ns) yield?), so a method can never be callable-but-unenumerable or the reverse.
namespace_statics_enumerable
The enumerable own keys of the builtin namespace ns — what for (key in ns) and Object.keys(ns) yield. These are the members node-js ACTUALLY implements, not Node’s full export list, so a package that copies a namespace key-by-key (safer-buffer clones buffer and Buffer) ends up with exactly the working set rather than an empty object. Whether a stdlib namespace’s statics are ENUMERABLE own properties. A core module’s exports and a node or WebIDL class’s statics (Buffer.from, URL.canParse) are; an ECMAScript intrinsic constructor’s are not (Iterator.from, Iterator.concat).
namespace_values
Non-callable members a namespace exports as enumerable VALUES — the nested modules and cross-links (timers.promises, assert.strict, path.posix, crypto.subtle). Listed apart from namespace_ctors because they are values rather than constructors; like fs.promises among the ctors, each read resolves through constant before any method thunk is considered.
native_parent
The method names a native instance tagged tag carries, as (its own list, the EventEmitter surface it also gets or empty).
native_tag
The hidden @@native instance tag of recv ("Buffer"/"Hash"/ "EventEmitter"/"URL"), or None for a non-native object.
resolve
singleton_class
A builtin SINGLETON kept as a namespace (performance, crypto, crypto.subtle) and the class it is the one instance of, under the key that class’s Builtin is spelled with. Every view of the instance — its prototype, instanceof, brand, constructor, own keys, hasOwnProperty, and its methods (read off the class prototype) — consults this one table.