nodejs版本的ByteBuffer和C++通信的利器!
var ByteBuffer = require('./ByteBuffer');
var sbuf = new ByteBuffer();
var buffer = sbuf.string('abc123你好')
.int32(-999).uint32(999).float(-0.5)
.int64(9999999).double(-0.000005).short(32767).ushort(65535)
.byte(255)
.vstring('abcd',5)
.pack();
console.log(buffer);
var rbuf = new ByteBuffer(buffer);
var arr = rbuf.string()
.int32().uint32().float()
.int64().double().short().ushort()
.byte()
.vstring(null,5)
.unpack();
console.log(arr);
var sbuf = new ByteBuffer().encoding('ascii');
var sbuf = new ByteBuffer().bigEndian();
var sbuf = new ByteBuffer(buffer,2);
var sbuf = new ByteBuffer();
sbuf.int32(9999,0);
var buffer = sbuf.pack(true);
install
npm install ByteBuffer -g