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
assertmodule. Failing assertions throw anAssertionError(returned as anErr, which the host surfaces as a thrown JS exception). - assert_
diff - The structural diff Node prints inside an
AssertionErrormessage. - async_
hooks - Node
async_hooksmodule — 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@@bytesarray;lengthis an enumerable data property sobuf.lengthreads directly. - child_
process - Node
child_processmodule — real subprocess execution viastd::process::Command. - cluster
- Node
cluster— real process-fork model overstd::process::Command. - console
- Node
consolemodule (require('console')), sharing the exact rendering the globalconsole.*uses: every argument is run throughJsHost::console_format(strings verbatim, everything else viautil.inspect) and space-joined — the same pipelinebuiltins::print_linedrives — so module output is identical to the global.log/info/debuggo to stdout;error/warn/trace/assertto stderr.count,groupandtimekeep per-thread state here (a monotonicInstantbacks the timers, sotimeEndreports a real elapsed duration). - constants
- The platform’s errno, signal and filesystem constants.
- crypto
- Node
cryptomodule. - 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@@msfield. - dgram
- Node
dgrammodule: real UDP sockets overstd::net::UdpSocket. - diagnostics_
channel - Node
diagnostics_channel— in-process publish/subscribe named channels. - dns
- Node
dnsmodule. - domain
- Node
domainmodule (deprecated in Node, implemented here with its real error-trapping semantics). ADomainis an EventEmitter (same@@native+@@on/@@onceshape asevents/net) whose defining behaviour isdomain.run(fn): it runsfnand, iffnthrows, emits the domain’s'error'event with the thrown value instead of propagating the throw. - events
- Node
eventsmodule:EventEmitter. The emitter is an object tagged@@native = "EventEmitter"with hidden@@on/@@oncemaps (event name → listener array).emitcollects 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,AbortControllerandAbortSignal. - fs
- Node
fsmodule: synchronous file operations, the async callback forms, and the file-descriptor / directory / stream / watcher surfaces. - fs_
promises - Node
fs/promises(alsorequire('fs').promises) — Promise-returning file operations. - http
- Node
httpmodule: an HTTP/1.1 server built on top ofnet. - http2
- Node
http2module: a REAL, minimal HTTP/2 server over TLS+ALPN. - https
- Node
httpsmodule: HTTP/1.1 over real TLS. - iterator
- Iterator helpers (27.1.4) —
map,filter,take,drop,flatMapand the terminalreduce/toArray/forEach/some/every/find, plus theIteratorconstructor andIterator.from. - net
- Node
netmodule: TCPServerandSocket. - node_
module - Node
modulecore module —require('module')(a.k.a.require('node:module')). - os
- Node
osmodule. 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
pathmodule — both flavors. - perf_
hooks - Node
perf_hooksmodule. - process
- Node
processglobal — the subset packages read at load time. - punycode
- Node
punycodemodule — 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
querystringmodule:parse/stringify(with theescape/unescapealiasesencode/decode). Values are percent-decoded/encoded with+standing for a space, the legacyapplication/x-www-form-urlencodedrules Node’squerystringuses (distinct from theqspackage express also ships). - readline
- Node
readlinemodule — a pragmatic, synchronous interface. - repl
- Node
replmodule —repl.start([options]). - stream
- Node
streammodule: native base classes + module helper functions. - stream_
consumers - Node
stream/consumersmodule: read an entire stream to a single value. - stream_
promises - Node
stream/promisesmodule: the Promise-basedfinishedandpipeline. - stream_
web - Node
stream/webmodule: the WHATWG Streams API over the host object heap. - string_
decoder - Node
string_decodercore 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
timersandtimers/promisesmodules. - tls
- Node
tlsmodule: real TLS over blockingrustls(rustls::StreamOwnedwrapping astd::net::TcpStream). - trace_
events - Node
trace_eventsmodule. - tty
- Node
ttymodule. - typedarray
- JavaScript typed arrays (
Uint8Array/Int8Array/…/Float64Array),ArrayBuffer,WeakRef, andTextEncoder/TextDecoder. - url
- Node
urlmodule: the WHATWGURLclass (global +require('url').URL) and the legacyurl.parse. AURLinstance stores its components as data properties (sou.hostnamereads directly) plus a@@native = "URL"tag fortoString. Assigning one of those components goes throughrefresh, which rewrites the DERIVED fields (href,host,origin) so the object cannot disagree with itself; thesearchParamsit carries holds an@@ownerUrlback-reference so its own mutations rewrite the query in the other direction. - url_
legacy - The legacy
url.parse/url.formatAPI — a faithful port of Node’slib/url.jsUrl.prototype.parse,Url.prototype.formatandurlFormat. - util
- Node
utilmodule:format,inspect, and a subset ofutil.types. - util_
types - Node
util.types— runtime type-tag predicates. - v8
- Node
v8module — a compatibility shim, NOT real V8 introspection. - vm
- Node
vmmodule — 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
zlibmodule — 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 throwsError: <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, ornamespace.method). ReturnsNoneifnameis 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 vianamespace_property. - construct
- Construct a stdlib class instance (
new URL(...),new EventEmitter(), andnew Buffer(...)legacy), reachable fromconstruct_builtin.Noneifnameis not a stdlib constructor. - data_
module - Canonical namespace name a
require(spec)resolves to (after stripping an optionalnode:prefix), orNonefor 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 aBuiltinhandle, whose members are dispatchable methods by construction. - has_
to_ json - Native instance tags whose
instance_callimplementstoJSON(), whichJSON.stringifymust invoke before serializing the value. (instance_has_methodonly covers tags with a declared method table;Datedispatches directly.) - instance_
accessor_ written - instance_
accessors - instance_
call - Dispatch a method call on a native stdlib instance (
recvcarries a@@nativetag). Called fromhost::call_methodbefore the generic object method resolution. - instance_
has_ method - Whether
nameis a method of a native instance taggedtag. Used byget_propertyso a method read (server.listen.apply(...), the express listen path) yields a bound method rather thanundefined— the method is still dispatched throughinstance_callwhen the bound method is invoked. - instance_
late_ methods - The ACCESSOR properties a native class’s prototype carries, as
(name, has_setter), and theSymbol.toStringTagit stamps (empty for none). - instance_
members_ enumerable - instance_
method_ lists - is_core
- Whether
specnames a core module of any kind — a method namespace or a data module. This is whatrequire.resolveanswers with the bare specifier. - is_
method - True if
qualified(namespace.method) is a stdlib method thatcall_builtin_functionshould route intocall(extendsis_known_builtin). - is_
unimplemented - True if
nsis a known-but-unimplemented core module (seeUNIMPLEMENTED_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, sofor (k in buffer)seesBuffer. - namespace_
keys - The enumerable own keys of the builtin namespace
ns— whatfor (key in ns)andObject.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 clonesbufferandBuffer) ends up with exactly the working set rather than an empty object. - namespace_
methods - The callable members of builtin namespace
ns. THE single table backing bothis_method(doesns.mdispatch?) andnamespace_keys(what doesfor (k in ns)yield?), so a method can never be callable-but-unenumerable or the reverse. - native_
parent - The method names a native instance tagged
tagcarries, as(its own list, the EventEmitter surface it also gets or empty). - native_
tag - The hidden
@@nativeinstance tag ofrecv("Buffer"/"Hash"/"EventEmitter"/"URL"), orNonefor a non-native object. - resolve