0.0.2 • Published 8 years ago
writebuf v0.0.2
writebuf
A buffer for writing ;)
Usage:
const WriteBuf = require('writebuf');
const w = new WriteBuf();
w.writeUInt16BE(20101);
w.writeBuffer(Buffer.from('Hello', 'utf8'));
console.log(w.buffer.toString('hex')); // 4e8548656c6c6fAPI Methods:
The WriteBuf class proxies the following Buffer methods for you to use:
writeInt16BEwriteInt16LEwriteInt32BEwriteInt32LEwriteInt8writeIntBEwriteIntLEwriteUInt16BEwriteUInt16LEwriteUInt32BEwriteUInt32LEwriteUInt8writeUIntBEwriteUIntLE
And it also provides these arbitrary methods:
writeInt24BEwriteInt24LEwriteUInt24BEwriteUInt24LEwriteBuffer
All of these except writeBuffer are fairly self-explanitory -- here's how writeBuffer works:
w.writeBuffer(<bufferResolvable>)Where bufferResolvable is either a Buffer, or an array of bytes Number(0 ~ 255)[].
To get the Buffer value of the WriteBuf, use w.buffer (a Getter).