mirror of
https://github.com/0x5eal/rbxts-pako.git
synced 2025-04-16 09:53:47 +01:00
better docs/works with errors/messages
This commit is contained in:
parent
eb234788e0
commit
f733a66266
3 changed files with 29 additions and 12 deletions
|
@ -45,12 +45,19 @@ function sliceBuf(buf, size) {
|
||||||
* custom handlers.
|
* custom handlers.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deflate.msg -> String
|
||||||
|
*
|
||||||
|
* Error message, if [[Deflate.err]] != 0
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* new Deflate(options)
|
* new Deflate(options)
|
||||||
* - options (Object): zlib deflate options.
|
* - options (Object): zlib deflate options.
|
||||||
*
|
*
|
||||||
* Creates new deflator instance with specified params. Supported options:
|
* Creates new deflator instance with specified params. Throws exception
|
||||||
|
* on bad params. Supported options:
|
||||||
*
|
*
|
||||||
* - `level`
|
* - `level`
|
||||||
* - `windowBits`
|
* - `windowBits`
|
||||||
|
@ -104,8 +111,10 @@ var Deflate = function(options) {
|
||||||
opt.windowBits += 16;
|
opt.windowBits += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ended = false; // used to avoid multiple onEnd() calls
|
this.err = 0; // error code, if happens (0 = Z_OK)
|
||||||
this.chunks = []; // chunks of compressed data
|
this.msg = ''; // error message
|
||||||
|
this.ended = false; // used to avoid multiple onEnd() calls
|
||||||
|
this.chunks = []; // chunks of compressed data
|
||||||
|
|
||||||
this.strm = new zstream();
|
this.strm = new zstream();
|
||||||
|
|
||||||
|
@ -224,8 +233,7 @@ Deflate.prototype.onEnd = function(status) {
|
||||||
}
|
}
|
||||||
this.chunks = [];
|
this.chunks = [];
|
||||||
this.err = status;
|
this.err = status;
|
||||||
// TODO: detect message by status, if not set in zstream
|
this.msg = msg[status];
|
||||||
this.msg = this.strm.msg || msg[status];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,19 @@ function sliceBuf(buf, size) {
|
||||||
* Should be checked if broken data possible.
|
* Should be checked if broken data possible.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inflate.msg -> String
|
||||||
|
*
|
||||||
|
* Error message, if [[Inflate.err]] != 0
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* new Inflate(options)
|
* new Inflate(options)
|
||||||
* - options (Object): zlib inflate options.
|
* - options (Object): zlib inflate options.
|
||||||
*
|
*
|
||||||
* Creates new inflator instance with specified params. Supported options:
|
* Creates new inflator instance with specified params. Throws exception
|
||||||
|
* on bad params. Supported options:
|
||||||
*
|
*
|
||||||
* - `windowBits`
|
* - `windowBits`
|
||||||
*
|
*
|
||||||
|
@ -90,12 +97,14 @@ var Inflate = function(options) {
|
||||||
opt.windowBits = -opt.windowBits;
|
opt.windowBits = -opt.windowBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ended = false; // used to avoid multiple onEnd() calls
|
this.err = 0; // error code, if happens (0 = Z_OK)
|
||||||
this.chunks = []; // chunks of compressed data
|
this.msg = ''; // error message
|
||||||
|
this.ended = false; // used to avoid multiple onEnd() calls
|
||||||
|
this.chunks = []; // chunks of compressed data
|
||||||
|
|
||||||
this.strm = new zstream();
|
this.strm = new zstream();
|
||||||
|
|
||||||
var status = zlib_inflate.inflateInit2(
|
var status = zlib_inflate.inflateInit2(
|
||||||
this.strm,
|
this.strm,
|
||||||
opt.windowBits
|
opt.windowBits
|
||||||
);
|
);
|
||||||
|
@ -206,8 +215,7 @@ Inflate.prototype.onEnd = function(status) {
|
||||||
}
|
}
|
||||||
this.chunks = [];
|
this.chunks = [];
|
||||||
this.err = status;
|
this.err = status;
|
||||||
// TODO: detect message by status, if not set in zstream
|
this.msg = msg[status];
|
||||||
this.msg = this.strm.msg || msg[status];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
var c = require('constants');
|
var c = require('constants');
|
||||||
|
|
||||||
|
// TODO: remove Z_NULL. Set proper values directly
|
||||||
function ZStream() {
|
function ZStream() {
|
||||||
/* next input byte */
|
/* next input byte */
|
||||||
this.next_in = c.Z_NULL;
|
this.next_in = c.Z_NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue