use the actual packer, not just the algorithm

This commit is contained in:
AJ ONeal 2017-02-15 23:15:17 -07:00
parent 05220405c6
commit 47829f9fa8
1 changed files with 16 additions and 10 deletions

View File

@ -13,10 +13,13 @@ if (!infile || !outfile) {
} }
var json = JSON.parse(fs.readFileSync(infile, 'utf8')); var json = JSON.parse(fs.readFileSync(infile, 'utf8'));
var data = require('fs').readFileSync(json.filepath, null);
var Packer = require('./index.js');
/*
function pack() {
var version = json.version; var version = json.version;
var address = json.address; var address = json.address;
var data = require('fs').readFileSync(json.filepath, null);
var header = address.family + ',' + address.address + ',' + address.port + ',' + data.byteLength var header = address.family + ',' + address.address + ',' + address.port + ',' + data.byteLength
+ ',' + (address.service || '') + ',' + (address.service || '')
; ;
@ -25,7 +28,10 @@ var buf = Buffer.concat([
, Buffer.from(header) , Buffer.from(header)
, data , data
]); ]);
}
*/
var buf = Packer.pack(json.address, data);
fs.writeFileSync(outfile, buf, null); fs.writeFileSync(outfile, buf, null);
console.log("wrote " + buf.byteLength + " bytes to '" + outfile + "' ('hexdump " + outfile + "' to inspect)"); console.log("wrote " + buf.byteLength + " bytes to '" + outfile + "' ('hexdump " + outfile + "' to inspect)");