Skip to content

Instantly share code, notes, and snippets.

@io4
Created March 10, 2017 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save io4/5d0fa80584d675d414938aeb6db11d67 to your computer and use it in GitHub Desktop.
Save io4/5d0fa80584d675d414938aeb6db11d67 to your computer and use it in GitHub Desktop.
Fixed code
function packFORMAT (data){
var body = BSON.serialize(data);
var cbody = Buffer(algorithm.compressFile(body),"binary");
var final = Buffer.concat([Buffer.from("MAGIC", "binary"), Buffer.from([data.origin.majorVersion,0x4,0x99,0x60])])
var dlen = body.length;
final = Buffer.concat([final,Buffer([dlen,dlen>>8,dlen>>16,dlen>>24],"binary")])
final = Buffer.concat([final,Buffer(cbody,"binary")]);
return final.toString("binary");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment