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).
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; length is an enumerable data property so buf.length reads directly.
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).
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.
events
Node events module: EventEmitter. The emitter is an object tagged @@native = "EventEmitter" with hidden @@on/@@once maps (event name → listener array). emit collects listeners, releases the host borrow, then invokes each so callbacks can re-enter the host.
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.
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 (POSIX semantics, matching macOS/Linux path).
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: parse/stringify (with the escape/unescape aliases encode/decode). Values are percent-decoded/encoded with + standing for a space, the legacy application/x-www-form-urlencoded rules Node’s querystring uses (distinct from the qs package express also ships).
readline
Node readline module — a pragmatic, synchronous interface.
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 over the host object heap.
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. A URL instance stores its components as data properties (so u.hostname reads directly) plus a @@native = "URL" tag for toString.
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§

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§

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).
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.
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.
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).
native_tag
The hidden @@native instance tag of recv ("Buffer"/"Hash"/ "EventEmitter"/"URL"), or None for a non-native object.
resolve
Canonical namespace name a require(spec) resolves to (after stripping an optional node: prefix), or None for an unsupported module.