mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-20 05:40:17 +08:00
* Expand static Effect support across common APIs * Preserve compiler parity across expanded Effect patterns * Fix compiler regressions exposed by Effect coverage * Bound shared type conversion traversal * Clarify conversion contracts and tidy fixtures * Run every Effect fixture in CI shards * Preserve inferred array assignments in concurrent Effect programs * Record inferred array fixture compiler ordering
18 lines
680 B
JavaScript
18 lines
680 B
JavaScript
function roundtrip(text, options) {
|
|
const value = JSON.parse(text, options?.reviver);
|
|
return JSON.stringify(value, options?.replacer, options?.space);
|
|
}
|
|
console.log(roundtrip('{"n":42}'));
|
|
console.log(roundtrip('{"n":42}', { reviver: null, replacer: null, space: 2 }));
|
|
console.log(roundtrip('{"n":42}', {
|
|
reviver(key, value) { return key === "n" ? value + 1 : value; },
|
|
replacer(key, value) { return key === "n" ? value * 2 : value; },
|
|
space: "--",
|
|
}));
|
|
let calls = 0;
|
|
try {
|
|
roundtrip("{", { reviver() { calls++; } });
|
|
} catch (error) { console.log(error.name, calls); }
|
|
const gap = process.argv[2];
|
|
console.log(JSON.stringify({ n: 1 }, (key, value) => value, gap));
|