Files
scriptc/tests/corpus/2462-qs-stringify.ts
Chris Tate 6b6445ab90 Retire the "DOM" nickname in comments, internal docs, and message prose: the checked-dynamic tree / dyn values
- The ratified rename rider (world-unification §7 lane 5): "DOM" collided with the browser DOM and, post-lane-1, the structure is no longer a document tree. Comments and doc prose now say "the checked-dynamic tree" for the noun and "dyn" adjectivally; runtime symbol names (scr_dyn_*), the error.domClone libCall, and the real web DOMException family are unchanged.
- The few user-facing strings carrying the nickname move with it (the structuredClone cyclic message, the dc subscriber/publish fences, two emitter ICE texts); diagnostics snapshots regenerated (96 pass). One private compiler constant (DOM_PROTO_METHOD_NAMES -> DYN_PROTO_METHOD_NAMES) rides along.
- Mechanical sweep, 142 files, comments/prose only — no behavior change.
2026-07-24 11:14:58 -05:00

41 lines
2.1 KiB
TypeScript

// node:querystring.stringify — Node's encodeStringified value rules
// (scr_qs.c over the dyn crossing): strings escape with the querystring
// set (spaces are %20, never '+'), finite numbers render shortest-
// roundtrip then escape ('1e+21' → '1e%2B21'), non-finite numbers and
// null/undefined are empty VALUES (key and eq still emitted), booleans
// are bare, arrays expand to repeated keys (empty arrays emit nothing at
// all), custom sep/eq apply verbatim with the falsy default rule, and
// keys escape like values. encode is Node's own alias.
import { stringify, encode } from "node:querystring";
console.log("T1", stringify({ a: 1, b: "x y", c: ["1", "2"], d: true, e: "" }));
console.log("T2", stringify({ a: Infinity, b: NaN, c: -0, d: 1e21, e: 0.1, f: -1.5 }));
console.log("T3", stringify({ "a b": "c", "☃": "+", "": "empty", k: "" }));
console.log("T4", JSON.stringify(stringify({})));
console.log("T5", stringify({ a: [] as string[], b: "x" }));
console.log("T6", stringify({ a: ["x", "y"] }, ";", ":"));
console.log("T7", stringify({ a: "1", b: "2" }, "", ""));
console.log("T8", stringify({ u: undefined, n: null, s: "v" } as Record<string, string | null | undefined>));
console.log("T9", stringify({ a: [1, 2.5, true] as (number | boolean)[] }));
console.log("T10", stringify({ "é☃": "é☃ 😀" }));
console.log("T11", stringify({ a: "x" }, "☃", "🌍"));
console.log("T12", encode({ x: [1, 2] }));
// Declared shapes with union-valued fields serialize by the value each
// field HOLDS (an explicitly-undefined optional field keeps its key with
// the empty value, exactly Node).
const o: { u?: string; s: string; n: number | null } = { u: undefined, s: "v", n: null };
console.log("T13", stringify(o));
// Index-signature records (the runtime-keyed build).
const r: Record<string, string | string[]> = {};
r["first"] = "1";
r["multi"] = ["a", "b"];
r["last"] = "z";
console.log("T14", stringify(r));
// The round trip: stringify(parse(qs)) is stable for canonical input.
import { parse } from "node:querystring";
const round = "a=1&a=2&b=x%20y&c=";
console.log("T15", stringify(parse(round)));