Skip to content

Instantly share code, notes, and snippets.

@iamcal
Created November 17, 2010 23:23
Show Gist options
  • Save iamcal/704324 to your computer and use it in GitHub Desktop.
Save iamcal/704324 to your computer and use it in GitHub Desktop.
function joinBuffers(b1, b2){
// if one arg is null, be smart
if (!b1) return b2;
if (!b2) return b1;
var l1 = b1.length;
var l2 = b2.length;
var b3 = new Buffer(l1 + l2);
b1.copy(b3, 0, 0, l1)
b2.copy(b3, l1, 0, l2);
return b3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment