Skip to content

Commit

Permalink
feat: toJSON serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
joundy committed Apr 6, 2024
1 parent 8f3b45b commit 1850891
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ async function main() {
]);
const decoded = U128.fromVaruint(buff).toValue();
console.log(decoded);

const u32 = new U32(32n)
console.log(JSON.stringify(u32))
}

main();
4 changes: 4 additions & 0 deletions src/varuint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export abstract class Varuint {
return this.n.toString();
}

toJSON(): string {
return this.n.toString();
}

toValue(): bigint {
return this.n;
}
Expand Down

0 comments on commit 1850891

Please sign in to comment.