Created
March 10, 2017 21:25
-
-
Save io4/5d0fa80584d675d414938aeb6db11d67 to your computer and use it in GitHub Desktop.
Fixed code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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