Files
scriptc/tests/corpus/destructure-inferred-row-defaults.js
Chris Tate bf21f47827 Compile collection metadata and heterogeneous JavaScript tables natively
- Preserve async factory results and mixed table layouts through inference and destructuring.
- Support checked Map and Object.fromEntries construction with native weak collections.
- Keep native weak-key lifetimes and engine-backed collection identities intact.
2026-09-28 22:20:24 -05:00

11 lines
419 B
JavaScript

function defineStruct(fields, options) {
const layout = [];
for (const [name, type, settings = {}] of fields) {
layout.push({ name, type, default: settings.default });
}
return layout;
}
const a = defineStruct([["first", "number", { default: 7 }], ["second", "number"]]);
const b = defineStruct([["name", "string", { default: "yes" }]], {});
console.log(a.length, a[0].default, a[1].default, b[0].default);