node-lz4 icon indicating copy to clipboard operation
node-lz4 copied to clipboard

Buffer.prototype.slice not working

Open dvdmor opened this issue 6 years ago • 2 comments
trafficstars

Hey,

I'm trying to run a simple example:

var Buffer = require('buffer').Buffer'; var LZ4 = require('lz4'); var input = new Buffer(itemToCompress); var output = new Buffer( LZ4.encodeBound(input.length) ); var compressedSize = LZ4.encodeBlock(input, output); output = output.slice(0, compressedSize);

input buffer size is 66293, compressedSize is 8002, and output buffer is 66568. However, slice doesn't seem to do anything to the buffer, and returns a buffer of the same size.

Am I missing something? Thanks!

dvdmor avatar Feb 22 '19 13:02 dvdmor

I cannot see the behaviour that you describe: the output buffer gets correctly resized according to the compressed size. Could you post a fully reproducible example?

pierrec avatar May 08 '19 14:05 pierrec

Update to the latest version. #83 seems to be the same problem and has been fixed

mesvam avatar Apr 02 '20 18:04 mesvam