infinity.zlib¶
Provides gzip compression and decompression functionality for strings, files and streams.
Module: infinity.zlib
Example:
infinity.loadModule('infinity.zlib');
let compressedData = infinity.zlib.compress('123456_123456_123456_123456_123456_123456_123456');
console.debug(compressedData);
//H4sIAAAAAAAECzM0MjYxNYs3JJYCAKTSqLQwAAAA
let extractedData = infinity.zlib.extract(compressedData);
console.debug(extractedData);
//123456_123456_123456_123456_123456_123456_123456
compress()¶
Compresses the given string with gzip and returns the results.
Signature:
compress( value: string ): string
Parameters:
- value:
string
The string to compress.
Return type: string
Example:
infinity.loadModule('infinity.zlib');
let compressedData = infinity.zlib.compress(dataToCompress);
compressFile()¶
Reads out the contents of a file, compresses them with gzip and writes the results to a file at the given location.
Signature:
compressFile( inFileName: string, outFileName: string ): void
Parameters:
-
inFileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which has to be compressed.
-
outFileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which should contain the encoded output.
Example:
infinity.loadModule('infinity.zlib');
infinity.zlib.compressFile('dataToCompress.txt', 'compressedData.gz');
compressStream()¶
Reads the contents of a stream, compresses them with gzip and writes the results to another given stream.
Signature:
compressStream( inStream: infinity.stream, outStream: infinity.stream ): void
Parameters:
-
inStream:
infinity.stream
The stream object to compress from. See infinity.stream.
-
outStream:
infinity.stream
The stream object to write to. See infinity.stream.
Example:
infinity.loadModule('infinity.zlib');
infinity.zlib.compressStream(inStream, outStream);
extract()¶
Attempts to decompress the given string with gzip and returns the results.
Signature:
extract( value: string ): string
Parameters:
- value:
string
The gzip-compressed contents to decompress.
Return type: string
Example:
infinity.loadModule('infinity.zlib');
let extractedData = infinity.zlib.extract(compressedData);
extractFile()¶
Reads out the contents of a file, attempts to decompress them with gzip, and writes the results to a file at the given location.
Signature:
extractFile( inFileName: string, outFileName: string ): void
Parameters:
-
inFileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to compressed file.
-
outFileName:
string
Filename, relative path (location relative to the folder with the used INFINITY.JS executable file) or absolute path to the file which should contain the decompressed output.
Example:
infinity.loadModule('infinity.zlib');
infinity.zlib.extractFile('compressedData.gz', 'extractedData.txt');
extractStream()¶
Reads the contents of a stream, attempts to decompress them with gzip, and writes the results to another given stream.
Signature:
extractStream( inStream: infinity.stream, outStream: infinity.stream ): void
Parameters:
-
inStream:
infinity.stream
The stream object to compress from. See infinity.stream.
-
outStream:
infinity.stream
The stream object to write to. See infinity.stream.
Example:
infinity.loadModule('infinity.zlib');
infinity.zlib.extractStream(inStream, outStream);