@dao-xyz/borsh
Advanced tools
Comparing version 3.2.4 to 3.2.5
@@ -20,3 +20,4 @@ "use strict"; | ||
const hex = num.toString(16); | ||
const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex'); | ||
const padded = hex.padStart(width * 2, '0').slice(0, width * 2); | ||
const buffer = Uint8Array.from(padded.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))); | ||
buffer.reverse(); | ||
@@ -23,0 +24,0 @@ return buffer; |
{ | ||
"name": "@dao-xyz/borsh", | ||
"version": "3.2.4", | ||
"version": "3.2.5", | ||
"readme": "README.md", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/dao-xyz/borsh-ts#README", |
@@ -68,3 +68,3 @@ # Borsh TS | ||
const value = new SomeClass({ x: 255, y: BigInt(20), z: 'abc', q: [1, 2, 3] }); | ||
const value = new SomeClass({ x: 255, y: 20n, z: 'abc', q: [1, 2, 3] }); | ||
@@ -242,4 +242,5 @@ // Serialize | ||
## Inheritance | ||
Schema generation is supported if deserialization is deterministic | ||
e.g. | ||
Schema generation is supported if deserialization is deterministic. In other words, all classes extending some super class needs to use discriminators/variants of the same type. | ||
Example: | ||
```typescript | ||
@@ -246,0 +247,0 @@ class A { |
@@ -340,3 +340,3 @@ import { BinaryReader } from "../binary"; | ||
} | ||
const instance = new Struct(BigInt(3)); | ||
const instance = new Struct(3n); | ||
const buf = serialize(instance); | ||
@@ -343,0 +343,0 @@ expect(buf).toEqual(new Uint8Array([3, ...new Array(31).fill(0)])); |
@@ -18,6 +18,6 @@ function arrayToHex(arr: Uint8Array): string { | ||
const hex = num.toString(16); | ||
const buffer = | ||
Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex'); | ||
const padded = hex.padStart(width * 2, '0').slice(0, width * 2); | ||
const buffer = Uint8Array.from(padded.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))); | ||
buffer.reverse(); | ||
return buffer; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
212899
4219
308