node package manager

netbuffer

General purpose & network buffer extensions.

Netbuffer

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');
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
stream.write(packet.toBuffer());
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();

	// ...

});