writeBytes(bytes: Array<number>) { let len = bytes.length; this.ensureCapacity(len + 4); this.writeInt(len); for (let i = 0; i < len; i++) { this.buf.writeUInt8(bytes[i], this.count++); } }
let fillLength = function (buf: Buffer, data: number, size: number) { let offset = size - 1, b; for (; offset >= 0; offset--) { b = data % LEFT_SHIFT_BITS; if (offset < size - 1) { b |= 0x80; } buf.writeUInt8(b, offset); data >>>= 7; } }
writeByte(v: number) { this.ensureCapacity(1); this.buf.writeUInt8(v, this.count++); }
function toBuffer(arr: any[]) { let buffer = new Buffer(arr.length); for (let i = 0; i < arr.length; i++) { buffer.writeUInt8(arr[i], i); } return buffer; }
writeBytes(buffer: Buffer, offset: number, bytes: Array<number>) { for (let i = 0; i < bytes.length; i++) { buffer.writeUInt8(bytes[i], offset); offset++; } return offset; }
let fillLength = function (buf: Buffer, data: number, size: number) { let offset = size - 1, b; for (; offset >= 0; offset--) { b = data % LEFT_SHIFT_BITS; if (offset < size - 1) { b |= 0x80; } buf.writeUInt8(b, offset); data >>>= 7; } }
writeBytes(bytes: Array<number>) { let len = bytes.length; this.ensureCapacity(len + 4); this.writeInt(len); for (let i = 0; i < len; i++) { this.buf.writeUInt8(bytes[i], this.count++); } }
writeByte(v: number) { this.ensureCapacity(1); this.buf.writeUInt8(v, this.count++); }