Skip to content

Commit

Permalink
hash-to-work-in-browser
Browse files Browse the repository at this point in the history
  • Loading branch information
uriva committed Feb 12, 2025
1 parent 07c7b63 commit 71c0ad3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 207 deletions.
212 changes: 7 additions & 205 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/io.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { sha256 } from "npm:js-sha256";
import { sha256 } from "jsr:@noble/hashes/sha2";
import { encodeHex } from "jsr:@std/encoding/hex";
import stableHash from "npm:stable-hash";
import { pipe } from "./composition.ts";
import { juxt, pairRight, stack } from "./juxt.ts";
Expand Down Expand Up @@ -172,4 +173,4 @@ export const retry = <F extends AsyncFunction>(

export const hash = <T>(x: T, maxLength: number) =>
// @ts-ignore-error error in deno but not in node
sha256.hex(stableHash(x)).substring(0, maxLength);
encodeHex(sha256(stableHash(x))).substring(0, maxLength);

0 comments on commit 71c0ad3

Please sign in to comment.