Module basic module

Module zlib

zlib compression and decompression module

Instructions:

1
var zlib = require('zlib');

Static function

createDeflate

Create a deflate stream object

1
static Stream zlib.createDeflate(Stream to);

Call parameters:

  • to : Stream , the stream used to store the processing results

Return result:

  • Stream , returns the encapsulated stream object

createDeflateRaw

Create a deflateRaw stream object

1
static Stream zlib.createDeflateRaw(Stream to);

Call parameters:

  • to : Stream , the stream used to store the processing results

Return result:

  • Stream , returns the encapsulated stream object

createGunzip

Create a gunzip stream object

1 2
static Stream zlib.createGunzip(Stream to, Integer maxSize = -1);

Call parameters:

  • to : Stream , the stream used to store the processing results
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

Return result:

  • Stream , returns the encapsulated stream object

createGzip

Create a gzip stream object

1
static Stream zlib.createGzip(Stream to);

Call parameters:

  • to : Stream , the stream used to store the processing results

Return result:

  • Stream , returns the encapsulated stream object

createInflate

Create an inflate stream object

1 2
static Stream zlib.createInflate(Stream to, Integer maxSize = -1);

Call parameters:

  • to : Stream , the stream used to store the processing results
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

Return result:

  • Stream , returns the encapsulated stream object

createInflateRaw

Create an inflateRaw stream object

1 2
static Stream zlib.createInflateRaw(Stream to, Integer maxSize = -1);

Call parameters:

  • to : Stream , the stream used to store the processing results
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

Return result:

  • Stream , returns the encapsulated stream object

deflate

Compress data using deflate algorithm (zlib format)

1 2
static Buffer zlib.deflate(Buffer data, Integer level = DEFAULT_COMPRESSION) async;

Call parameters:

  • data : Buffer , given the data to be compressed
  • level : Integer, specify the compression level, the default is DEFAULT_COMPRESSION

Return result:

  • Buffer , returns the compressed binary data

deflateTo

Use the deflate algorithm to compress data into a stream object (zlib format)

1 2 3
static zlib.deflateTo(Buffer data, Stream stm, Integer level = DEFAULT_COMPRESSION) async;

Call parameters:

  • data : Buffer , given the data to be compressed
  • stm : Stream , specifies the stream for storing compressed data
  • level : Integer, specify the compression level, the default is DEFAULT_COMPRESSION

Use the deflate algorithm to compress the data in the source stream into the stream object (zlib format)

1 2 3
static zlib.deflateTo(Stream src, Stream stm, Integer level = DEFAULT_COMPRESSION) async;

Call parameters:

  • src : Stream , the stream where the data to be compressed is given
  • stm : Stream , specifies the stream for storing compressed data
  • level : Integer, specify the compression level, the default is DEFAULT_COMPRESSION

inflate

Decompress data compressed by deflate algorithm (zlib format)

1 2
static Buffer zlib.inflate(Buffer data, Integer maxSize = -1) async;

Call parameters:

  • data : Buffer , given compressed data
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

Return result:

  • Buffer , returns the uncompressed binary data

inflateTo

Decompress the data compressed by the deflate algorithm into a stream object (zlib format)

1 2 3
static zlib.inflateTo(Buffer data, Stream stm, Integer maxSize = -1) async;

Call parameters:

  • data : Buffer , given the data to be decompressed
  • stm : Stream , specifies the stream for storing decompressed data
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

Decompress the data compressed by the deflate algorithm in the source stream to the stream object (zlib format)

1 2 3
static zlib.inflateTo(Stream src, Stream stm, Integer maxSize = -1) async;

Call parameters:

  • src : Stream , the stream where the data to be decompressed is given
  • stm : Stream , specifies the stream for storing decompressed data
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

gzip

Compress data using gzip algorithm

1
static Buffer zlib.gzip(Buffer data) async;

Call parameters:

  • data : Buffer , given the data to be compressed

Return result:

  • Buffer , returns the compressed binary data

gzipTo

Use gzip algorithm to compress data into stream objects

1 2
static zlib.gzipTo(Buffer data, Stream stm) async;

Call parameters:

  • data : Buffer , given the data to be compressed
  • stm : Stream , specifies the stream for storing compressed data

Use the gzip algorithm to compress the data in the source stream into the stream object

1 2
static zlib.gzipTo(Stream src, Stream stm) async;

Call parameters:

  • src : Stream , the stream where the data to be compressed is given
  • stm : Stream , specifies the stream for storing compressed data

gunzip

Decompress data compressed by gzip algorithm

1 2
static Buffer zlib.gunzip(Buffer data, Integer maxSize = -1) async;

Call parameters:

  • data : Buffer , given compressed data
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

Return result:

  • Buffer , returns the uncompressed binary data

gunzipTo

Decompress the data compressed by the gzip algorithm into the stream object

1 2 3
static zlib.gunzipTo(Buffer data, Stream stm, Integer maxSize = -1) async;

Call parameters:

  • data : Buffer , given the data to be decompressed
  • stm : Stream , specifies the stream for storing decompressed data
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

Decompress the data compressed by the gzip algorithm in the source stream to the stream object

1 2 3
static zlib.gunzipTo(Stream src, Stream stm, Integer maxSize = -1) async;

Call parameters:

  • src : Stream , the stream where the data to be decompressed is given
  • stm : Stream , specifies the stream for storing decompressed data
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

deflateRaw

Use the deflate algorithm to compress data (deflateRaw)

1 2
static Buffer zlib.deflateRaw(Buffer data, Integer level = DEFAULT_COMPRESSION) async;

Call parameters:

  • data : Buffer , given the data to be compressed
  • level : Integer, specify the compression level, the default is DEFAULT_COMPRESSION

Return result:

  • Buffer , returns the compressed binary data

deflateRawTo

Use the deflate algorithm to compress data into a stream object (deflateRaw)

1 2 3
static zlib.deflateRawTo(Buffer data, Stream stm, Integer level = DEFAULT_COMPRESSION) async;

Call parameters:

  • data : Buffer , given the data to be compressed
  • stm : Stream , specifies the stream for storing compressed data
  • level : Integer, specify the compression level, the default is DEFAULT_COMPRESSION

Use the deflate algorithm to compress the data in the source stream into the stream object (deflateRaw)

1 2 3
static zlib.deflateRawTo(Stream src, Stream stm, Integer level = DEFAULT_COMPRESSION) async;

Call parameters:

  • src : Stream , the stream where the data to be compressed is given
  • stm : Stream , specifies the stream for storing compressed data
  • level : Integer, specify the compression level, the default is DEFAULT_COMPRESSION

inflateRaw

Decompress data compressed by the deflate algorithm (inflateRaw)

1 2
static Buffer zlib.inflateRaw(Buffer data, Integer maxSize = -1) async;

Call parameters:

  • data : Buffer , given compressed data
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

Return result:

  • Buffer , returns the uncompressed binary data

inflateRawTo

Decompress the data compressed by the deflate algorithm into the stream object (inflateRaw)

1 2 3
static zlib.inflateRawTo(Buffer data, Stream stm, Integer maxSize = -1) async;

Call parameters:

  • data : Buffer , given the data to be decompressed
  • stm : Stream , specifies the stream for storing decompressed data
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

Decompress the data compressed by the deflate algorithm in the source stream to the stream object (inflateRaw)

1 2 3
static zlib.inflateRawTo(Stream src, Stream stm, Integer maxSize = -1) async;

Call parameters:

  • src : Stream , the stream where the data to be decompressed is given
  • stm : Stream , specifies the stream for storing decompressed data
  • maxSize : Integer, specify the decompression size limit, the default is -1, no limit

constant

NO_COMPRESSION

deflate compression level, set no compression

1
const zlib.NO_COMPRESSION = 0;

BEST_SPEED

deflate compression level, set the fastest compression

1
const zlib.BEST_SPEED = 1;

BEST_COMPRESSION

deflate compression level, set the highest compression

1
const zlib.BEST_COMPRESSION = 9;

DEFAULT_COMPRESSION

deflate compression level, set default settings

1
const zlib.DEFAULT_COMPRESSION = -1;