Skip to content

Instantly share code, notes, and snippets.

@KOBA789
Created March 15, 2011 19:38
Show Gist options
  • Select an option

  • Save KOBA789/871297 to your computer and use it in GitHub Desktop.

Select an option

Save KOBA789/871297 to your computer and use it in GitHub Desktop.
NodeのBufferを連結する何か
var buf1 = new Buffer([0xe3, 0x81]);
var buf2 = new Buffer([0x82, 0xe3, 0x81, 0x84])
Buffer.prototype.push = function (buf) {
var newBuf = new Buffer(this.length + buf.length);
this.copy(newBuf);
buf.copy(newBuf, this.length);
return newBuf;
}
console.log(buf1.push(buf2));
console.log(buf1.push(buf2).toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment