Extract stable serialization infrastructure into VG-Core
Dieser Commit ist enthalten in:
@@ -7,24 +7,3 @@ async function sha256Hex(input) {
|
||||
.map((byte) => byte.toString(16).padStart(2, "0"))
|
||||
.join("");
|
||||
}
|
||||
|
||||
function stableStringify(value) {
|
||||
return JSON.stringify(sortObjectKeys(value));
|
||||
}
|
||||
|
||||
function sortObjectKeys(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(sortObjectKeys);
|
||||
}
|
||||
|
||||
if (value && typeof value === "object") {
|
||||
return Object.keys(value)
|
||||
.sort()
|
||||
.reduce((result, key) => {
|
||||
result[key] = sortObjectKeys(value[key]);
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
function stableStringify(value) {
|
||||
return JSON.stringify(sortObjectKeys(value));
|
||||
}
|
||||
|
||||
function sortObjectKeys(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(sortObjectKeys);
|
||||
}
|
||||
|
||||
if (value && typeof value === "object") {
|
||||
return Object.keys(value)
|
||||
.sort()
|
||||
.reduce((result, key) => {
|
||||
result[key] = sortObjectKeys(value[key]);
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren