this module help build package
''' var makePackage = function(buffer, size){ for (var i = 1; i < size; i++) {
if (buffer.readInt8(i-1) == 13 && buffer.readInt8(i) == 10){
return {
offset: i + 1,
package: buffer.toString("ascii", 0, i - 1)
};
}
};
return null;
};
'''
''' var sentences = []; var inputs = new Buffer("hello\r\nworld\r\n");
var instance = BufferPackager({ makePackage: makePackage }); instance.on("data", function(pkg){ sentences.push (pkg); }); instance.push(inputs); assert.equal(2, sentences.length); assert.equal('hello', sentences[0]); assert.equal('world', sentences[1]); '''
emit when package success
emit when error got