Rewrite nested ternaries (#18508)
This commit is contained in:
1 parent
9bf7f1b971
commit
97f2e81d06
16 files changed
+187
-127
No files matched your search
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user