pierrec / node-lz4

LZ4 fast compression algorithm for NodeJS
MIT License
438 stars 98 forks source link

Can not compress an empty stream #44

Closed ChALkeR closed 8 years ago

ChALkeR commented 8 years ago

Using the example from the Readme:

var fs = require('fs')
var lz4 = require('lz4')

var encoder = lz4.createEncoderStream()

var input = fs.createReadStream('test')
var output = fs.createWriteStream('test.lz4')

input.pipe(encoder).pipe(output)

If test is a zero-size file, then the example crashes with

…/node_modules/lz4/lib/utils.js:19
                return XXH.digest(c)
                           ^

TypeError: Wrong arguments
    at TypeError (native)
    at Object.exports.streamChecksum (…/node_modules/lz4/lib/utils.js:19:14)
    at Encoder._flush (…/node_modules/lz4/lib/encoder_stream.js:210:27)
    at Encoder.<anonymous> (_stream_transform.js:118:12)
    at Encoder.g (events.js:286:16)
    at emitNone (events.js:86:13)
    at Encoder.emit (events.js:185:7)
    at prefinish (_stream_writable.js:478:12)
    at finishMaybe (_stream_writable.js:486:7)
    at endWritable (_stream_writable.js:498:3)