ycbuffer
v0.0.4
Published
Buffer utils
Downloads
2
Readme
ycbuffer
Node.js Buffer utils
BufferReaderBE/BufferReaderLE
var BufferReaderBE = require('ycbuffer').BufferReaderBE;
var buffer = new Buffer('12123412345678414243444546', 'hex');
var r = new BufferReaderBE(buffer);
r.u8 (0) === 0x12;
r.u16(1) === 0x1234;
r.u32(3) === 0x12345678;
r.str(7, 3) === 'ABC';
r.buf(10, 3).toString() === 'DEF'
BufferWriterBE/BufferWriterLE
var BufferWriterBE = require('ycbuffer').BufferWriterBE;
var buffertool = require('ycbuffer').buffertool;
var buffer = new Buffer(13);
var expect = new Buffer('12123412345678414243444546', 'hex');
var w = new BufferWriterBE(buffer);
w.u8 (0, 0x12);
w.u16(1, 0x1234);
w.u32(3, 0x12345678);
w.str(7, 'ABC');
w.buf(10, new Buffer('DEF'))
buffertool.equal(buffer, expect);
buffertool.equal
see the above example
Development
npm test
npm run-script build