byte-data-stream
Readable & writable byte data stream
Usage
const fs = require('fs');
const { ByteStream,ByteStreamSimulator } = require('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;
stream.readInt8();
stream.readUint8();
stream.readBytes(length);
stream.readInt16(littleEndian);
stream.readUint16(littleEndian);
stream.readInt32(littleEndian);
stream.readUint32(littleEndian);
stream.readBigInt64(littleEndian);
stream.readBigUint64(littleEndian);
stream.readFloat32(littleEndian);
stream.readFloat64(littleEndian);
stream.readVarInt(littleEndian,maxByteLength = Infinity);
stream.readVarUint(littleEndian,maxByteLength = Infinity);
stream.writeInt8(val);
stream.writeUint8(val);
stream.writeBytes(bytes);
stream.writeInt16(val,littleEndian);
stream.writeUint16(val,littleEndian);
stream.writeInt32(val,littleEndian);
stream.writeUint32(val,littleEndian);
stream.writeBigInt64(val,littleEndian);
stream.writeBigUint64(val,littleEndian);
stream.writeFloat32(val,littleEndian);
stream.writeFloat64(val,littleEndian);
stream.writeVarInt(val,littleEndian);
stream.writeVarUint(val,littleEndian);