byte-data-stream
Readable & writable byte data stream
Usage
import fs from 'fs';
import { ByteStream, ByteStreamSimulator } from 'byte-data-stream';
let buf = fs.readFileSync('......');
let stream = new ByteStream(buf);
stream.readInt8();
stream.readUint8();
stream.readBytes(8);
stream.readInt16();
stream.readUint16(true);
stream.readVarUint();
let stream2 = new ByteStream();
stream2.writeInt8(96);
stream2.writeUint8(192);
stream2.writeBytes([19, 72, 11, 21, 19, 72, 11, 21]);
stream2.writeInt16(1972);
stream2.writeUint16(49861, true);
stream2.writeVarUint(92736296525);
let simulator = new ByteStreamSimulator();
simulator.length;
All methods
stream.i;
stream.buffer;
stream.length;
stream.isDataAvailable;
new ByteStream(buf, (littleEndian = false));
stream.readInt8();
stream.readUint8();
stream.readBytes(length);
stream.readInt16(oppositeEndian);
stream.readUint16(oppositeEndian);
stream.readInt32(oppositeEndian);
stream.readUint32(oppositeEndian);
stream.readBigInt64(oppositeEndian);
stream.readBigUint64(oppositeEndian);
stream.readFloat32(oppositeEndian);
stream.readFloat64(oppositeEndian);
stream.readVarInt(oppositeEndian, (maxByteLength = Infinity));
stream.readVarUint(oppositeEndian, (maxByteLength = Infinity));
stream.writeInt8(val);
stream.writeUint8(val);
stream.writeBytes(bytes);
stream.writeInt16(val, oppositeEndian);
stream.writeUint16(val, oppositeEndian);
stream.writeInt32(val, oppositeEndian);
stream.writeUint32(val, oppositeEndian);
stream.writeBigInt64(val, oppositeEndian);
stream.writeBigUint64(val, oppositeEndian);
stream.writeFloat32(val, oppositeEndian);
stream.writeFloat64(val, oppositeEndian);
stream.writeVarInt(val, oppositeEndian);
stream.writeVarUint(val, oppositeEndian);