better docs/works with errors/messages

master
Vitaly Puzrin 2014-02-20 21:29:22 +04:00
rodzic eb234788e0
commit f733a66266
3 zmienionych plików z 29 dodań i 12 usunięć

Wyświetl plik

@ -45,12 +45,19 @@ function sliceBuf(buf, size) {
* custom handlers.
**/
/**
* Deflate.msg -> String
*
* Error message, if [[Deflate.err]] != 0
**/
/**
* new 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`
* - `windowBits`
@ -104,8 +111,10 @@ var Deflate = function(options) {
opt.windowBits += 16;
}
this.ended = false; // used to avoid multiple onEnd() calls
this.chunks = []; // chunks of compressed data
this.err = 0; // error code, if happens (0 = Z_OK)
this.msg = ''; // error message
this.ended = false; // used to avoid multiple onEnd() calls
this.chunks = []; // chunks of compressed data
this.strm = new zstream();
@ -224,8 +233,7 @@ Deflate.prototype.onEnd = function(status) {
}
this.chunks = [];
this.err = status;
// TODO: detect message by status, if not set in zstream
this.msg = this.strm.msg || msg[status];
this.msg = msg[status];
};

Wyświetl plik

@ -43,12 +43,19 @@ function sliceBuf(buf, size) {
* Should be checked if broken data possible.
**/
/**
* Inflate.msg -> String
*
* Error message, if [[Inflate.err]] != 0
**/
/**
* new 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`
*
@ -90,12 +97,14 @@ var Inflate = function(options) {
opt.windowBits = -opt.windowBits;
}
this.ended = false; // used to avoid multiple onEnd() calls
this.chunks = []; // chunks of compressed data
this.err = 0; // error code, if happens (0 = Z_OK)
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,
opt.windowBits
);
@ -206,8 +215,7 @@ Inflate.prototype.onEnd = function(status) {
}
this.chunks = [];
this.err = status;
// TODO: detect message by status, if not set in zstream
this.msg = this.strm.msg || msg[status];
this.msg = msg[status];
};

Wyświetl plik

@ -2,6 +2,7 @@
var c = require('constants');
// TODO: remove Z_NULL. Set proper values directly
function ZStream() {
/* next input byte */
this.next_in = c.Z_NULL;