Skip to content

Commit f0a2362

Browse files
authored
feat: output and accept base64url instead of base64 (#30)
1 parent d7c1408 commit f0a2362

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"packageManager": "[email protected]",
6262
"dependencies": {
6363
"bson": "^4.7.2",
64-
"byte-base64": "^1.1.0",
64+
"js-base64": "^3.7.5",
6565
"lodash.clonedeep": "^4.5.0",
6666
"lz4js": "^0.2.0"
6767
},

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EJSON } from 'bson';
2-
import { base64ToBytes } from 'byte-base64';
2+
import { Base64 } from 'js-base64';
33
import { decompress } from 'lz4js';
44

55
export type ParseTypeGuardFunction<T> = (obj: any) => obj is T;
@@ -165,7 +165,7 @@ function unminifyKeys(
165165
export function decompressString(str: string): string {
166166
try {
167167
return new TextDecoder().decode(
168-
Uint8Array.from(decompress(base64ToBytes(str)))
168+
Uint8Array.from(decompress(Base64.toUint8Array(str)))
169169
);
170170
} catch (err: unknown) {
171171
// str is not a base64 encoded string of a byte array

src/stringify.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EJSON } from 'bson';
2-
import { bytesToBase64 } from 'byte-base64';
2+
import { Base64 } from 'js-base64';
33
import cloneDeep from 'lodash.clonedeep';
44
import { compress } from 'lz4js';
55
import {
@@ -251,5 +251,7 @@ function minifyKeys(
251251
}
252252

253253
export function compressString(str: string): string {
254-
return bytesToBase64(compress(new TextEncoder().encode(str)));
254+
return Base64.fromUint8Array(
255+
compress(new TextEncoder().encode(str)) as Uint8Array
256+
);
255257
}

0 commit comments

Comments
 (0)