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.read_int8();
stream.read_uint8();
stream.read_bytes(8);
stream.read_int16();
stream.read_uint16(true);
stream.read_var_uint();
let stream2 = new ByteStream();
stream2.write_int8(96);
stream2.write_uint8(192);
stream2.write_bytes([19,72,11,21,19,72,11,21]);
stream2.write_int16(1972);
stream2.write_uint16(49861,true);
stream2.write_var_uint(92736296525);
let simulator = new ByteStreamSimulator();
simulator.length;
All methods
stream.i;
stream.buffer;
stream.read_int8();
stream.read_uint8();
stream.read_bytes(length);
stream.read_int16(little_endian);
stream.read_uint16(little_endian);
stream.read_int32(little_endian);
stream.read_uint32(little_endian);
stream.read_big_int64(little_endian);
stream.read_big_uint64(little_endian);
stream.read_float32(little_endian);
stream.read_float64(little_endian);
stream.read_var_int(little_endian,max_byte_length = Infinity);
stream.read_var_uint(little_endian,max_byte_length = Infinity);
stream.write_int8(val);
stream.write_uint8(val);
stream.write_bytes(bytes);
stream.write_int16(val,little_endian);
stream.write_uint16(val,little_endian);
stream.write_int32(val,little_endian);
stream.write_uint32(val,little_endian);
stream.write_big_int64(val,little_endian);
stream.write_big_uint64(val,little_endian);
stream.write_float32(val,little_endian);
stream.write_float64(val,little_endian);
stream.write_var_int(val,little_endian);
stream.write_var_uint(val,little_endian);