0.3.1 • Public • Published

    Nodestream - Compress Transform

    NPM Version Build Status Coverage Status Documentation Status Built with GNU Make

    Zlib compression/decompression transform for Nodestream

    Identity:: compress

    API docs


    This transformer allows you to compress/decompress streams that you upload/download with Nodestream. Same functionality as with the built-in zlib module is supported.

    You can use any combination of compressing/decompressing and downloading/uploading - you are not limited to ie. only compressing uploads and decompressing downloads.



    npm install --save nodestream-transform-compress


    You need to register this tranform with Nodestream before you can use it:

    // Assuming you already have a nodestream instance configured with an adapter

    Now you can create a pipeline which will use this transform:

    const pipeline = nodestream.pipeline()
      .use('checksum', {
        algorithm: 'gzip',  // Either gzip or deflate, gzip is default
        raw: false  // For deflate, setting this to true will not prepend deflate header

    The following options are supported:

    • algorithm: Either gzip or deflate - determines which compression algorithm should be used
    • raw: true or false - Only available for deflate algorithm. If set to true, then no header will be added to the resulting stream.

    The following per-file options are required:

    • mode: Either compress or decompress - determines how the stream should be transformed

    Pass this option via the last argument in .upload() or .download() methods on the pipeline via a compress key (this transform's identity) - see the examples below.


    This transform does not have any transformation results to publish, so it will publish the input configuration which was used for this transformation - it will be available on the compress property (this transform's identity) on the results response:

    const file = fs.createReadStream('/users/me/profile-pic.png')
    pipeline.upload(file, { name: 'avatar.png', compress: { mode: 'compress' } })
    .then(results => {
      results.compress.algorithm  // gzip
      results.compress.raw  // false
    // Downloads
    const dest = fs.createWriteStream('/users/me/profile-pic.png')'avatars/user-123.png', dest, { compress: { mode: 'decompress' } })
    .then(results => {
      results.compress.algorithm  // gzip
      results.compress.raw  // false


    This software is licensed under the BSD-3-Clause License. See the LICENSE file for more information.


    npm i nodestream-transform-compress

    DownloadsWeekly Downloads






    Last publish


    • dreamscapes