Сериализация / Бинарный формат

//using Node.js
//npm install avsc

class Size {
    public width: number
     public height: number

     constructor(width: number, height: number) {
        this.width = width
        this.height = height
    }
}

class Rect {
    public size: Size

     constructor(size: Size) {
        this.size = size
    }
}

let rect = new Rect(new Size(510))
const avsc = require('avsc')
const type = avsc.Type.forValue(rect)

const data_b = type.toBuffer(rect)
//data_b is <Buffer 0a 14>
console.log("data_b is", data_b)