Skip to content

Commit 4916f61

Browse files
fix jsdoc. again.
1 parent efbe6aa commit 4916f61

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

json/unstable_canonicalize.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,18 @@ export function canonicalize(value: JsonValue): string {
167167
* import { encodeHex } from "@std/encoding/hex";
168168
* import { assertEquals } from "@std/assert";
169169
*
170+
* async function sha256Hex(data: Uint8Array): Promise<string> {
171+
* const hash = await crypto.subtle.digest("SHA-256", data.buffer.slice(0));
172+
* return encodeHex(new Uint8Array(hash));
173+
* }
174+
*
170175
* // Create a deterministic hash of JSON data for verification
171176
* const payload = { action: "transfer", amount: 100, to: "alice" };
172-
* const bytes = canonicalizeToBytes(payload);
173-
* const hashBuffer = await crypto.subtle.digest("SHA-256", bytes.buffer);
174-
* const hash = encodeHex(new Uint8Array(hashBuffer));
177+
* const hash = await sha256Hex(canonicalizeToBytes(payload));
175178
*
176179
* // Same hash regardless of original key order
177180
* const reordered = { to: "alice", action: "transfer", amount: 100 };
178-
* const reorderedBytes = canonicalizeToBytes(reordered);
179-
* const reorderedHash = encodeHex(
180-
* new Uint8Array(await crypto.subtle.digest("SHA-256", reorderedBytes.buffer)),
181-
* );
181+
* const reorderedHash = await sha256Hex(canonicalizeToBytes(reordered));
182182
*
183183
* assertEquals(hash, reorderedHash);
184184
* ```

0 commit comments

Comments
 (0)