node_erlastic
node_erlastic copied to clipboard
compressed binary support
Hey,
I have a patch for bert.js that adds compressed binary support, however it requires node.js 0.12 at minimum, due to a bug in the zlib implementation in prior versions.
Is that acceptable, and if so, should I submit a PR?
Thanks!
Hello, Yes it is OK to require node.js 0.12, my projects actually use io.js on earlier versions, maybe you can also add the requirement to the package.json.
Thank you very much for the proposal, I actually wanted to add this support.
:+1:
:+1:
@Cidan : is this done ..
having trouble to decode Compressed Term Format:

Fix was very non-intuitive
const { unzip } = require('node:zlib');
const { promisify } = require('node:util');
const do_unzip = promisify(unzip);
//remove the first 6 bytes and inflate using zlib
const inflated = await do_unzip(buffer.subarray(6));
//we are skipping check for 131 in decode function rest of logic in decode function is the same
var Obj = Bert.decode_inner(inflated);
if (Obj.rest.length !== 0) {
throw ("Invalid BERT.");
}
return Obj.value;