Support up to node v9 (#110)

* Fix compatibility issues with node 9.

* Fix async tests.
This commit is contained in:
Ryo Kawaguchi 2018-04-20 05:04:14 +09:00 committed by Luke Page
parent 32d0580228
commit 0a6201df87
3 changed files with 17 additions and 0 deletions

View file

@ -5,3 +5,6 @@ node_js:
- "4"
- "5"
- "6"
- "7"
- "8"
- "9"

View file

@ -41,6 +41,14 @@ ParserAsync.prototype._handleError = function(err) {
this._inflate.destroy();
}
if (this._filter) {
this._filter.destroy();
// For backward compatibility with Node 7 and below.
// Suppress errors due to _inflate calling write() even after
// it's destroy()'ed.
this._filter.on('error', function() {});
}
this.errord = true;
};

View file

@ -17,6 +17,10 @@ function Inflate(opts) {
zlib.Inflate.call(this, opts);
// Node 8 --> 9 compatibility check
this._offset = this._offset === undefined ? this._outOffset : this._offset;
this._buffer = this._buffer || this._outBuffer;
if (opts && opts.maxLength != null) {
this._maxLength = opts.maxLength;
}
@ -110,6 +114,8 @@ Inflate.prototype._processChunk = function(chunk, flushFlag, asyncCb) {
this._buffer, // out
this._offset, //out_off
availOutBefore); // out_len
// Node 8 --> 9 compatibility check
res = res || this._writeState;
} while (!this._hadError && handleChunk(res[0], res[1]));
if (this._hadError) {