Skip to content

Commit

Permalink
switch to base32-encoding to support cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer committed Aug 18, 2024
1 parent 8b08ca8 commit 4b34de0
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 66 deletions.
16 changes: 8 additions & 8 deletions dist/index.all.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.all.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/index.cjs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/node/index.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/node/index.js

Large diffs are not rendered by default.

65 changes: 28 additions & 37 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest --collectCoverage"
},
"dependencies": {
"base32-encode": "^2.0.0",
"@types/base32-encoding": "^1.0.2",
"base32-encoding": "^1.0.0",
"hash-wasm": "^4.11.0",
"pako": "^1.0.11",
"tempy": "^3.1.0",
Expand Down
9 changes: 6 additions & 3 deletions src/lib/warcserializer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//import base32 from "hi-base32";
import base32Encode from "base32-encode";
import base32 from "base32-encoding";
import pako from "pako";

import { createSHA256, createSHA1 } from "hash-wasm";
Expand Down Expand Up @@ -189,7 +188,7 @@ export class WARCSerializer extends BaseAsyncIterReader
return (
this.digestAlgoPrefix +
(this.digestBase32
? base32Encode(hasher.digest("binary"), "RFC4648")
? base32Encode(hasher.digest("binary"))
: hasher.digest("hex"))
);
}
Expand Down Expand Up @@ -264,3 +263,7 @@ export class WARCSerializer extends BaseAsyncIterReader
}
}

function base32Encode(buff: Uint8Array) : string {
return base32.stringify(buff, "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");
}

0 comments on commit 4b34de0

Please sign in to comment.