dict sort

commit_hash:4cd6c531b4c11371be1731d2a1635aebe095d457
This commit is contained in:
4eb0da
2026-05-05 14:32:11 +03:00
parent 6d3da8b773
commit 362ad71a58
3 changed files with 18 additions and 3 deletions
+14 -1
View File
@@ -36,6 +36,19 @@ export function dateToString(date: Date): string {
].join(':');
}
function stringifySortReplacer(key: string, value: unknown): unknown {
if (value && value instanceof Object && !Array.isArray(value)) {
return Object.keys(value)
.sort()
.reduce<Record<string, unknown>>((sorted, key) => {
sorted[key] = value[key as keyof typeof value];
return sorted;
}, {});
}
return value;
}
export function valToString(val: EvalValue, stringifyComplex: boolean): string {
if (val.type === 'string') {
return val.value;
@@ -64,7 +77,7 @@ export function valToString(val: EvalValue, stringifyComplex: boolean): string {
} else if (val.type === 'url') {
return val.value;
} else if ((val.type === 'dict' || val.type === 'array') && stringifyComplex) {
return JSON.stringify(val.value);
return JSON.stringify(val.value, stringifySortReplacer);
} else if (val.type === 'dict') {
return '<dict>';
} else if (val.type === 'array') {
@@ -289,7 +289,8 @@
}
],
"platforms": [
"ios"
"ios",
"web"
]
},
{
@@ -183,7 +183,8 @@
}
],
"platforms": [
"ios"
"ios",
"web"
]
},
{