cartodb-4.42/lib/assets/javascripts/cdb/scripts/check_size.js
2024-04-06 05:25:13 +00:00

25 lines
639 B
JavaScript

/*
* this utility reports the size of a layergroup compressed
* usage:
* node check_size.js layergroup.json
*/
var lzma = require("lzma").LZMA();
var fs = require('fs');
function _array2hex (byteArr) {
var encoded = [];
for(var i = 0; i < byteArr.length; ++i) {
encoded.push(String.fromCharCode(byteArr[i] + 128));
}
buffer = new Buffer(encoded.join(''), 'binary');
return buffer.toString('base64');
}
var str = fs.readFileSync(process.argv[2]);
lzma.compress(str, 1, function(result) {
console.log("size (raw/compressed/base64 compressed): ", str.length, "/", result.length, "/", _array2hex(result).length);
});