|
|
jsz
jsz module
jsz module
home > JSLibs > jsz --
![]()
Description
This module manage zlib data compression and decompression. more.
Example
var deflate = new Z( Z.DEFLATE, 9 );
var clearData;
var compressedData;
for ( var i = 10; i >= 0; --i ) {
var chunk = randomString(10000);
compressedData += deflate( chunk );
clearData += chunk;
}
compressedData += deflate(); // flush
var inflate = new Z( Z.INFLATE );
var clearData2 = inflate( compressedData, true );
Print( 'ratio:' + compressedData.length + ': ' + Math.round( 100 * compressedData.length / clearData.length ) + '%','\n');
if ( clearData2 != clearData )
Print('error!!!','\n');
}jsz::Z class
home > JSLibs > jsz > Z -![]()
Description
Functions
- constructor Z( method [, compressionLevel ] )
Constructs a new inflater or deflater object.The method can be Z.DEFLATE to compress data or Z.INFLATE to decompress data. The compression level is like this: 0 <= compressionLevel <= 9.
note:
For Z.INFLATE method, compressionLevel argument is useless ( no sense )example:
var compress = new Z( Z.DEFLATE, 9 );
- outputData call operator( [ inputData [, forceFinish = false ] ] )
This function process inputData as a stream. If forceFinish is true, the inputData and any buffered data are flushed to the outputData. If this function is call without any argument, All remaining data are flushed. If eof has already reach, the function returns an empty outputData string.example:
var compress = new Z( Z.DEFLATE ); var compressedData = compress( 'Hello '); compressedData += compress( 'world' ); compressedData += compress(); // flushexample:
var compress = new Z( Z.DEFLATE ); var compressedData = compress( 'Hello '); compressedData += compress( 'world', true ); // flushexample:
var compressedData = new Z( Z.DEFLATE )( 'Hello world', true ); // flush
Properties
- eof
Is true if the end of the stream has been reach.
- adler32
Contains the adler32 checksum of the data. more.
- lengthIn
Contains the current total amount of input data.
- lengthOut
Contains the current total amount of output data.
Static Properties
- idealInputLength
This is the ideal size of input data to avoid buffer management overload.
Constants
- Z.DEFLATE
Compression method.
- Z.INFLATE
Decompression method.
jsz::ZError class
home > JSLibs > jsz -![]()
Description
You cannot construct this class. Its aim is to throw as an exception on any zlib runtime error.
Properties
Exemple
...
Sign in to add a comment


