avsc-tsc
v1.0.6
Published
Utility library to encode and decode typescript classes in Avro format
Downloads
4,336
Readme
Avro TSC Decorators
Installation
npm install avsc-tsc
Usage
- Decorators
import { Avro, AvroField, AvroSchema } from 'avsc-tsc';
@AvroSchema({ namespace: 'evm' })
class Block extends Avro {
@AvroField(['string', 'null'])
number: number
@AvroField(['string', 'null'])
hash: number
}
- Encoding
const block = new Block()
const encoded = await block.encode()
- Decoding
const decoded = await Block.decode<Block>(encoded)