Question

I'm using the ZLibDeflater to compress a file, by reading it as a stream and transforming it:

new File(filePath)
   .openRead()
   .transform(new ZLibDeflater())
   .pipe(new File(gzipPath).openWrite())
   .then(...);

As the ZLibDeflater is now deprecated, how can I convert the code to use the new GZipCodec class?

Was it helpful?

Solution

You can also use ZLIB :

new File(filePath)
  .openRead()
  .transform(ZLIB.decoder)
  .pipe(new File(zlibPath).openWrite())
  .then(...);

OTHER TIPS

Gave up to early, you can simply do it using the Converter.bind() method to transform a stream:

const GZipCodec()
    .encoder.bind(new File(filePath).openRead())
    .pipe(new File(gzipPath).openWrite())
    .then(...)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top