UNPKG

@tf2pickup-org/mumble-client

Version:
30 lines 858 B
export function writeVarint(value) { if (value < 0) { const positive = writeVarint(-value); return Buffer.concat([Buffer.from([0xf8]), positive]); } if (value < 0x80) { return Buffer.from([value]); } if (value < 0x4000) { const buf = Buffer.alloc(2); buf.writeUint16BE(value | 0x8000); return buf; } if (value < 0x200000) { const buf = Buffer.alloc(3); buf.writeUint16BE((value >> 8) | 0xc000, 0); buf.writeUint8(value & 0xff, 2); return buf; } if (value < 0x10000000) { const buf = Buffer.alloc(4); buf.writeUint32BE((value | 0xe0000000) >>> 0); return buf; } const buf = Buffer.alloc(5); buf.writeUint8(0xf0, 0); buf.writeUint32BE(value, 1); return buf; } //# sourceMappingURL=write-varint.js.map