mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-24 06:14:01 +08:00
Represent ordinary JavaScript arrays with hole, value, and explicit-undefined states; add sparse side storage and carry missing values through the frontend, native backends, runtime, and Node-facing consumers.
14 lines
528 B
TypeScript
14 lines
528 B
TypeScript
// Array-derived missing string keys use JavaScript ToPropertyKey: undefined -> "undefined".
|
|
const keys: string[] = ["a"];
|
|
keys.length = 2;
|
|
const source: Record<string, string> = { a: "A", undefined: "U" };
|
|
const target: Record<string, string> = {};
|
|
for (const key of keys) {
|
|
console.log("read", typeof key, source[key]);
|
|
target[key] = typeof key;
|
|
}
|
|
console.log("write", target.a, target.undefined);
|
|
|
|
const rows: { value: number }[] = [{ value: 1 }];
|
|
for (const row of rows) console.log("keys", Object.keys(row).join(","));
|