writebuf
v0.0.2
Published
A small, auto-expanding version of Node's Buffer.
Downloads
3
Readme
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')); // 4e8548656c6c6f
API Methods:
The WriteBuf
class proxies the following Buffer methods for you to use:
writeInt16BE
writeInt16LE
writeInt32BE
writeInt32LE
writeInt8
writeIntBE
writeIntLE
writeUInt16BE
writeUInt16LE
writeUInt32BE
writeUInt32LE
writeUInt8
writeUIntBE
writeUIntLE
And it also provides these arbitrary methods:
writeInt24BE
writeInt24LE
writeUInt24BE
writeUInt24LE
writeBuffer
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).