Releases: dao-xyz/borsh-ts
Releases · dao-xyz/borsh-ts
5.2.3
5.2.2
- fix: reset cached deserialisation behaviour on dynamic imports. This will allow dynamically imported classes to also be considered for Enum deserialisation
5.2.1
- feat: Custom class serializer
Custom class serialization that is useful if you want to override serialization behaviour, like doing caching
Example
import { serializer } from '@dao-xyz/borsh'
class TestStruct {
@field({type: 'u8'})
public number: number;
constructor(number: number) {
this.number = number;
}
cache: Uint8Array | undefined;
@serializer()
override(writer: BinaryWriter, serialize: (obj: this) => Uint8Array) {
if (!this.cache) {
this.cache = serialize(this)
}
writer.set(this.cache)
}
}
5.1.8
5.1.7
- fix: Throw
BorshError
instead ofError
on failing to decode bool and u8
5.1.6
- fix: add overflow checks for string decoding to coerce behaviours between protobuf/utf8 and Buffer.toString()
5.1.5
- Prevent unbound allocation for arrays on deserialization
- Reduce call stack depth when deserializing many elements
5.1.4
5.1.3
- Bug fix: Prevent u256 and u512 deserialization modifying the original serialized byte array when passed as Buffer
5.1.2
- Faster u64 serialization by handling small numbers differently
Benchmark below. Protobuf does not deserialize into bigint so these benchmarks are not easily comparable.
borsh u64 with bigint x 5,385,093 ops/sec ±0.44% (389 runs sampled)
protobujs u64 with bigint x 7,022,500 ops/sec ±0.53% (393 runs sampled)
borsh u64 with number x 6,124,037 ops/sec ±0.42% (393 runs sampled)
protobujs u64 with number x 4,639,581 ops/sec ±0.35% (394 runs sampled)