node/lib/internal
Filip Skokan 1c16b45d35
lib: refactor internal webidl converters
Rework lib/internal/webidl.js into a documented shared converter module
that follows the Web IDL conversion algorithms more closely.

Improvements:
- Add documented converters and helper factories for primitive values,
  dictionaries, enums, sequences, interfaces, required arguments,
  integers, `Uint8Array`, and `BufferSource`.
- Move WebCrypto onto the shared converters, while keeping compatibility
  wrappers for its existing `BufferSource` and `BigInteger` behavior.
- Use shared converters from Blob, Performance, Web Locks, and
  structured clone option handling.
- Add benchmarks for `ConvertToInt` and WebCrypto Web IDL converter hot
  paths.
- Add focused tests for core converters, WebCrypto converters, integer
  conversion, and buffer source behavior.

Fixes:
- Make the shared `BufferSource` and `Uint8Array` converters reject
  resizable `ArrayBuffer` and growable `SharedArrayBuffer` backing
  stores unless explicitly allowed. WebCrypto preserves its legacy
  resizable backing-store behavior through compatibility wrappers until
  a semver-major follow-up can opt in to the stricter behavior.
- Use Web IDL `ToNumber` and `ToString` behavior for BigInt, Symbol, and
  object primitive conversion.
- Use exact BigInt modulo for 64-bit `ConvertToInt` wrapping and
  document the final Number approximation behavior.
- Normalize mathematical modulo results to `+0` where Web IDL requires
  it.
- Process inherited dictionaries in least-derived to most-derived order,
  sorting members only within each dictionary level.
- Use `IteratorComplete` truthiness for sequence conversion.
- Cover detached buffers, resizable-backed views, growable-backed views,
  cross-realm buffer sources, mutation-after-call behavior, inherited
  dictionary member order, and sequence iterator completion behavior.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62979
Backport-PR-URL: https://github.com/nodejs/node/pull/63563
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-06-23 01:06:46 +01:00
..
assert
async_local_storage
bootstrap quic: move quic behind compile time flag 2026-05-07 17:32:44 +02:00
child_process
cluster
console
crypto lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
debugger debugger: add --help to node inspect and improve docs 2026-06-18 00:15:51 +02:00
dns dns,net: reject hostnames with embedded NUL bytes 2026-06-17 20:02:06 +02:00
encoding lib: fix typo idenity => identity 2026-06-18 00:15:52 +02:00
errors
events
fs fs: make Date properties on Stats enumerable 2026-06-18 00:15:54 +02:00
http2 http2: emit session close before stream close 2026-06-18 21:12:35 +01:00
inspector inspector: coerce key and value to string in webstorage events 2026-05-09 09:32:20 +02:00
legacy
main watch: fix --env-file-if-exists crashing on linux if the file is missing 2026-05-07 15:41:38 +02:00
modules module: load ESM helpers eagerly in the snapshot 2026-06-18 21:12:36 +01:00
per_context
perf lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
process permission: handle process.chdir on writereport 2026-06-17 20:02:05 +02:00
quic crypto: harden KeyObject internal slots 2026-06-23 01:06:39 +01:00
readline
repl repl: fix dedup comparing normalized line against raw history 2026-06-18 00:15:53 +02:00
source_map lib: fix source map url parse in dynamic imports 2026-04-10 14:52:18 +02:00
streams stream: switch to internal sleep binding 2026-06-18 21:12:36 +01:00
test
test_runner test_runner: dont buffer unordered events in process isolation mode 2026-06-18 21:12:33 +01:00
tls tls: add unsupported renegotiation error 2026-06-18 00:15:50 +02:00
util crypto: harden KeyObject internal slots 2026-06-23 01:06:39 +01:00
v8 lib: avoid quadratic shift() in startup snapshot callback 2026-05-07 15:41:47 +02:00
vm
watch_mode watch: fix --env-file-if-exists crashing on linux if the file is missing 2026-05-07 15:41:38 +02:00
webstreams stream: fix Writable.toWeb() hang on synchronous drain 2026-06-18 21:12:33 +01:00
worker lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
abort_controller.js lib: defer AbortSignal.any() following 2026-05-07 15:41:32 +02:00
assert.js
async_context_frame.js
async_hooks.js
blob.js lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
blocklist.js
buffer.js
child_process.js child_process: add tracing channel for spawn 2026-04-10 14:52:12 +02:00
cli_table.js
constants.js
data_url.js
dgram.js
encoding.js
error_serdes.js
errors.js tls: add unsupported renegotiation error 2026-06-18 00:15:50 +02:00
event_target.js
file.js
fixed_queue.js
freelist.js
freeze_intrinsics.js
heap_utils.js
histogram.js
http.js lib,test: redact proxy credentials in tunnel errors 2026-06-17 20:02:05 +02:00
inspector_async_hook.js
inspector_network_tracking.js
js_stream_socket.js
linkedlist.js
locks.js lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
mime.js
navigator.js
net.js tls: forward keepAlive, keepAliveInitialDelay, noDelay to socket 2026-04-10 14:52:15 +02:00
options.js doc: fix node-config-schema 2026-05-07 18:14:56 +02:00
priority_queue.js
promise_hooks.js
querystring.js
README.md
repl.js
socket_list.js
socketaddress.js
stream_base_commons.js
timers.js
trace_events_async_hooks.js
tty.js
url.js url: optimize URLSearchParams set/delete duplicate handling 2026-05-07 15:41:46 +02:00
util.js util: remove unused functions 2026-06-18 21:12:37 +01:00
v8_prof_polyfill.js
validators.js lib: fixes validator message 2026-06-18 00:15:52 +02:00
vm.js
wasm_web_api.js
watchdog.js
webidl.js lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
webstorage.js inspector: auto collect webstorage data 2026-05-09 09:32:20 +02:00
worker.js watch: track worker entry files in watch mode 2026-05-07 15:41:48 +02:00

Internal Modules

The modules located in lib/internal directory are exclusively meant for internal usage within the Node.js core. They are not intended to be accessed via user modules require(). These modules may change at any point in time. Relying on these internal modules outside the core is not supported and can lead to unpredictable behavior.

In certain scenarios, accessing these internal modules for debugging or experimental purposes might be necessary. Node.js provides the --expose-internals flag to expose these modules to userland code. This flag only exists to assist Node.js maintainers with debugging internals. It is not meant for use outside the project.