General purpose & network buffer extensions.

npm install netbuffer
16 downloads in the last week
32 downloads in the last month


Netbuffer is a helper library to build any form of binary data from scratch into a buffer.


npm install netbuffer

Access the the library like this:

var nb = require('netbuffer');


Creating a writer

var packet = new nb.NetWriter();
packet.writeString("JohnDoe");    // name
packet.writeInt8(10);            // level
packet.writeInt32(500000);        // experience
packet.writeInt16(152);            // posx
packet.writeInt16(123);            // posy

Converting the writer to a buffer


Converting a buffer to a reader and reading data

socket.on('data', function(buffer) {

    // ...

    var packet = buffer.toNetReader();
    var name = packet.readString();
    var level = packet.readInt8();
    var experience = packet.readInt32();
    var posx = packet.readInt16();
    var posy = packet.readInt16();

    // ...

npm loves you