Rewrite nested ternaries (#18508)

This commit is contained in:
fisker Cheung authored and GitHub committed 2025-12-21 18:07:47 +08:00
1 parent 9bf7f1b971
commit 97f2e81d06
16 files changed
+187 -127

No files matched your search

+15 -8
View File
@@ -70,14 +70,21 @@ function serializeError(error) {
function serializeAst(ast) {
return JSON.stringify(
ast,
(_, value) =>
value instanceof Error
? serializeError(value)
: typeof value === "bigint"
? `BigInt('${String(value)}')`
: typeof value === "symbol"
? String(value)
: value,
(_, value) => {
if (value instanceof Error) {
return serializeError(value);
}
if (typeof value === "bigint") {
return `BigInt('${String(value)}')`;
}
if (typeof value === "symbol") {
return String(value);
}
return value;
},
2,
);
}