You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: expose TextEncoder/TextDecoder from ns:util and node:util
Matches the updated NativeScript/ios#448. The lazy tier's private exports
cache generalizes into BuiltinLoader::GetExports, one per-isolate cache
every entry point to a builtin shares — the ns:/node: module registry
(whose per-specifier exports map it replaces), the lazy globals, and any
binding factory. ns:util re-exports TextEncoder/TextDecoder as the very
class objects the globals hold, lazily end to end (SetLazyDataProperty on
the binding, getters in ns-util.js/node-util.js), and node:util forwards
them as Node does.
Copy file name to clipboardExpand all lines: docs/ns-builtin-modules.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,7 @@ Rules:
59
59
|---|---|
60
60
|`inspect(value[, options])`| Formats any value for human consumption: depth-limited, output-capped, cycle-safe, never invokes getters (except a guarded `error.stack` read and custom `toString` overrides, which are honored). `options.depth` (number) overrides the default depth of 2. Other option keys are reserved. |
61
61
|`format(fmt, ...args)`| Node-style printf formatting: `%s`, `%d`, `%i`, `%f`, `%j`, `%o`, `%O`, `%%`. Extra arguments are appended space-separated, objects rendered via `inspect`. When `fmt` is not a string or contains no substitutions, all arguments are formatted and joined with spaces. `console.*` routes its arguments through this, so `console.log("%d apples", 3)` works. |
62
+
|`TextEncoder` / `TextDecoder`| The WHATWG encoding interfaces, **the very same class objects the globals of those names hold** (`require("ns:util").TextDecoder === globalThis.TextDecoder`). Reading either member is what materializes them, so requiring the module costs nothing extra. |
**Stability caveat (verbatim from Node's contract):** the output of `inspect`
82
90
(and therefore `format`'s object rendering) may change between runtime
83
91
versions for readability; it is intended for humans and must not be parsed
@@ -400,7 +408,7 @@ unmodified where a shim exists:
400
408
401
409
| module | exports | notes |
402
410
|---|---|---|
403
-
| `node:util` | `inspect`, `format`| Re-exports `ns:util`'s members unchanged (`nodeUtil.inspect===nsUtil.inspect`) from a **distinct, separately frozen module object**. Documented as partial. |
411
+
| `node:util` | `inspect`, `format`, `TextEncoder`, `TextDecoder`| Re-exports `ns:util`'s members unchanged (`nodeUtil.inspect===nsUtil.inspect`) from a **distinct, separately frozen module object**. `TextEncoder`/`TextDecoder` are the globals of those names, as they are in Node. Documented as partial. |
404
412
| `node:url` | `fileURLToPath`, `pathToFileURL` | Node-strict converters between `file:` URLs and paths. Documented as partial — no `URL`/`URLSearchParams` re-exports (both are globals), no legacy `url.parse`/`format`/`resolve`. |
405
413
| `node:module` | `createRequire` | Re-exports `ns:module`'s `createRequire` unchanged from a **distinct, separately frozen module object**. `createPumpingRequire` is deliberately absent: it has no Node counterpart, so code written against this shim keeps running on Node. `require.resolve`/`.cache`/`.main` are not implemented, and neither is any other `node:module` member (`Module`, `builtinModules`, `isBuiltin`, `register`, `syncBuiltinESMExports`). Documented as partial. |
0 commit comments