We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ee2065 commit 2732911Copy full SHA for 2732911
test/codec-bigint.test.ts
@@ -5,11 +5,15 @@ const extensionCodec = new ExtensionCodec();
5
extensionCodec.register({
6
type: 0,
7
encode: (input: unknown) => {
8
- if (typeof input === "bigint") {
9
- return encode(input.toString());
10
- } else {
11
- return null;
12
- }
+ if (typeof input === "bigint") {
+ if (input <= Number.MAX_SAFE_INTEGER && input >= Number.MIN_SAFE_INTEGER) {
+ return encode(parseInt(input.toString(), 10));
+ } else {
+ return encode(input.toString());
13
+ }
14
15
+ return null;
16
17
},
18
decode: (data: Uint8Array) => {
19
return BigInt(decode(data));
0 commit comments