Module zlib
zlib compression and decompression module
Instructions:
1var zlib = require('zlib');
Static function
createDeflate
Create a deflate stream object
1static Stream zlib.createDeflate(Stream to);
Call parameters:
- to: Stream, The stream used to store the processing results
Return result:
- Stream, Return the encapsulated stream object
createDeflateRaw
Create a deflateRaw stream object
1static Stream zlib.createDeflateRaw(Stream to);
Call parameters:
- to: Stream, The stream used to store the processing results
Return result:
- Stream, Return the encapsulated stream object
createGunzip
Create a gunzip stream object
1
2static 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, Return the encapsulated stream object
createGzip
Create a gzip stream object
1static Stream zlib.createGzip(Stream to);
Call parameters:
- to: Stream, The stream used to store the processing results
Return result:
- Stream, Return the encapsulated stream object
createInflate
Create an inflate stream object
1
2static 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, Return the encapsulated stream object
createInflateRaw
Create an inflateRaw stream object
1
2static 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, Return the encapsulated stream object
deflate
Use deflate algorithm to compress data (zlib format)
1
2static 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, Return compressed binary data
deflateTo
Use the deflate algorithm to compress data into a stream object (zlib format)
1
2
3static zlib.deflateTo(Buffer data,
Stream stm,
Integer level = DEFAULT_COMPRESSION) async;
Call parameters:
- data: Buffer, Given the data to be compressed
- stm: Stream, Specify 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
3static zlib.deflateTo(Stream src,
Stream stm,
Integer level = DEFAULT_COMPRESSION) async;
Call parameters:
- src: Stream, Given the stream where the data to be compressed is located
- stm: Stream, Specify 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
2static 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, Return the uncompressed binary data
inflateTo
Decompress the data compressed by the deflate algorithm into a stream object (zlib format)
1
2
3static zlib.inflateTo(Buffer data,
Stream stm,
Integer maxSize = -1) async;
Call parameters:
- data: Buffer, Given the data to be decompressed
- stm: Stream, Specify 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
3static zlib.inflateTo(Stream src,
Stream stm,
Integer maxSize = -1) async;
Call parameters:
- src: Stream, Given the stream where the data to be decompressed is located
- stm: Stream, Specify the stream for storing decompressed data
- maxSize: Integer, specify the decompression size limit, the default is -1, no limit
gzip
Use gzip algorithm to compress data
1static Buffer zlib.gzip(Buffer data) async;
Call parameters:
- data: Buffer, Given the data to be compressed
Return result:
- Buffer, Return compressed binary data
gzipTo
Use the gzip algorithm to compress data into the stream object
1
2static zlib.gzipTo(Buffer data,
Stream stm) async;
Call parameters:
- data: Buffer, Given the data to be compressed
- stm: Stream, Specify the stream for storing compressed data
Use the gzip algorithm to compress the data in the source stream into the stream object
1
2static zlib.gzipTo(Stream src,
Stream stm) async;
Call parameters:
- src: Stream, Given the stream where the data to be compressed is located
- stm: Stream, Specify the stream for storing compressed data
gunzip
Decompress data compressed by gzip algorithm
1
2static 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, Return the uncompressed binary data
gunzipTo
Decompress the data compressed by the gzip algorithm into the stream object
1
2
3static zlib.gunzipTo(Buffer data,
Stream stm,
Integer maxSize = -1) async;
Call parameters:
- data: Buffer, Given the data to be decompressed
- stm: Stream, Specify 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
3static zlib.gunzipTo(Stream src,
Stream stm,
Integer maxSize = -1) async;
Call parameters:
- src: Stream, Given the stream where the data to be decompressed is located
- stm: Stream, Specify 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
2static 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, Return compressed binary data
deflateRawTo
Use the deflate algorithm to compress data into a stream object (deflateRaw)
1
2
3static zlib.deflateRawTo(Buffer data,
Stream stm,
Integer level = DEFAULT_COMPRESSION) async;
Call parameters:
- data: Buffer, Given the data to be compressed
- stm: Stream, Specify 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
3static zlib.deflateRawTo(Stream src,
Stream stm,
Integer level = DEFAULT_COMPRESSION) async;
Call parameters:
- src: Stream, Given the stream where the data to be compressed is located
- stm: Stream, Specify the stream for storing compressed data
- level: Integer, specify the compression level, the default is DEFAULT_COMPRESSION
inflateRaw
Decompress the data compressed by the deflate algorithm (inflateRaw)
1
2static 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, Return the uncompressed binary data
inflateRawTo
Decompress the data compressed by the deflate algorithm into the stream object (inflateRaw)
1
2
3static zlib.inflateRawTo(Buffer data,
Stream stm,
Integer maxSize = -1) async;
Call parameters:
- data: Buffer, Given the data to be decompressed
- stm: Stream, Specify 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
3static zlib.inflateRawTo(Stream src,
Stream stm,
Integer maxSize = -1) async;
Call parameters:
- src: Stream, Given the stream where the data to be decompressed is located
- stm: Stream, Specify 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
1const zlib.NO_COMPRESSION = 0;
BEST_SPEED
deflate compression level, set the fastest compression
1const zlib.BEST_SPEED = 1;
BEST_COMPRESSION
deflate compression level, set the highest compression
1const zlib.BEST_COMPRESSION = 9;
DEFAULT_COMPRESSION
deflate compression level, set default settings
1const zlib.DEFAULT_COMPRESSION = -1;