aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/tar/node_modules/minizlib/index.js
diff options
context:
space:
mode:
authorMyles Borins <myles.borins@gmail.com>2017-10-26 22:44:44 -0400
committerMyles Borins <myles.borins@gmail.com>2017-10-29 21:32:40 -0400
commit9f33a248b37ed5acb31cffe2483d5dfc3db89521 (patch)
tree6a909195e71040e7bb9062af555acf0b060f267c /deps/npm/node_modules/tar/node_modules/minizlib/index.js
parentace4fe566fc3af4876c7458f983feeb5eae3df26 (diff)
downloadandroid-node-v8-9f33a248b37ed5acb31cffe2483d5dfc3db89521.tar.gz
android-node-v8-9f33a248b37ed5acb31cffe2483d5dfc3db89521.tar.bz2
android-node-v8-9f33a248b37ed5acb31cffe2483d5dfc3db89521.zip
deps: backport 4ca695819 from npm upstream
Original commit message: minizlib@1.0.4 Fixes Node 9 compatibility. Credit: @isaacs PR-URL: https://github.com/nodejs/node/pull/16509 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'deps/npm/node_modules/tar/node_modules/minizlib/index.js')
-rw-r--r--deps/npm/node_modules/tar/node_modules/minizlib/index.js35
1 files changed, 28 insertions, 7 deletions
diff --git a/deps/npm/node_modules/tar/node_modules/minizlib/index.js b/deps/npm/node_modules/tar/node_modules/minizlib/index.js
index 7d595dec4f..8c0df2ac43 100644
--- a/deps/npm/node_modules/tar/node_modules/minizlib/index.js
+++ b/deps/npm/node_modules/tar/node_modules/minizlib/index.js
@@ -52,6 +52,7 @@ const _offset = Symbol('offset')
const _level = Symbol('level')
const _strategy = Symbol('strategy')
const _ended = Symbol('ended')
+const _writeState = Symbol('writeState')
class Zlib extends MiniPass {
constructor (opts, mode) {
@@ -127,11 +128,27 @@ class Zlib extends MiniPass {
var strategy = typeof opts.strategy === 'number' ? opts.strategy
: constants.Z_DEFAULT_STRATEGY
- this[_handle].init(opts.windowBits || constants.Z_DEFAULT_WINDOWBITS,
- level,
- opts.memLevel || constants.Z_DEFAULT_MEMLEVEL,
- strategy,
- opts.dictionary)
+ this[_writeState] = new Uint32Array(2);
+ const window = opts.windowBits || constants.Z_DEFAULT_WINDOWBITS
+ const memLevel = opts.memLevel || constants.Z_DEFAULT_MEMLEVEL
+
+ // API changed in node v9
+ /* istanbul ignore next */
+ if (/^v[0-8]\./.test(process.version)) {
+ this[_handle].init(window,
+ level,
+ memLevel,
+ strategy,
+ opts.dictionary)
+ } else {
+ this[_handle].init(window,
+ level,
+ memLevel,
+ strategy,
+ this[_writeState],
+ () => {},
+ opts.dictionary)
+ }
this[_buffer] = Buffer.allocUnsafe(this[_chunkSize])
this[_offset] = 0
@@ -234,11 +251,15 @@ class Zlib extends MiniPass {
this[_offset], //out_off
availOutBefore // out_len
)
+
if (this[_hadError])
break
- let availInAfter = res[0]
- let availOutAfter = res[1]
+ // API changed in v9
+ /* istanbul ignore next */
+ let availInAfter = res ? res[0] : this[_writeState][1]
+ /* istanbul ignore next */
+ let availOutAfter = res ? res[1] : this[_writeState][0]
const have = availOutBefore - availOutAfter
assert(have >= 0, 'have should not go down')