byte-data-stream
๋ฐ์ดํธ ๋ฐ์ดํฐ๋ฅผ ์ฝ๊ณ ์ธ ์ ์๋ ์คํธ๋ฆผ
API ๋ฌธ์
English README
์ฌ์ฉ๋ฒ
CommonJS์ require()
ํจ์๋ 2.0.0 ์ด์ ๋ฒ์ ๋ถํฐ ๋ ์ด์ ์ง์๋์ง ์์ต๋๋ค.
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;
์ ์ฒด ํจ์ ๋ชฉ๋ก
stream.i;
stream.buffer;
stream.length;
stream.isDataAvailable;
new ByteStream(length, littleEndian = false);
new ByteStream(buf, littleEndian = false);
stream.readInt8();
stream.readUint8();
stream.readBytes(length);
stream.readBytesUntilEnd();
stream.readInt16(oppositeEndian = false);
stream.readUint16(oppositeEndian = false);
stream.readInt32(oppositeEndian = false);
stream.readUint32(oppositeEndian = false);
stream.readBigInt64(oppositeEndian = false);
stream.readBigUint64(oppositeEndian = false);
stream.readFloat32(oppositeEndian = false);
stream.readFloat64(oppositeEndian = false);
stream.readVarInt(oppositeEndian = false, maxByteLength = Infinity);
stream.readVarUint(oppositeEndian = false, maxByteLength = Infinity);
stream.writeInt8(val);
stream.writeUint8(val);
stream.writeBytes(bytes);
stream.writeInt16(val, oppositeEndian = false);
stream.writeUint16(val, oppositeEndian = false);
stream.writeInt32(val, oppositeEndian = false);
stream.writeUint32(val, oppositeEndian = false);
stream.writeBigInt64(val, oppositeEndian = false);
stream.writeBigUint64(val, oppositeEndian = false);
stream.writeFloat32(val, oppositeEndian = false);
stream.writeFloat64(val, oppositeEndian = false);
stream.writeVarInt(val, oppositeEndian = false);
stream.writeVarUint(val, oppositeEndian = false);