0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

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>
This commit is contained in:
Myles Borins 2017-10-26 22:44:44 -04:00
parent ace4fe566f
commit 9f33a248b3
No known key found for this signature in database
GPG Key ID: 933B01F40B5CA946
2 changed files with 42 additions and 21 deletions

View File

@ -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')

View File

@ -1,27 +1,27 @@
{
"_from": "minizlib@^1.0.3",
"_id": "minizlib@1.0.3",
"_from": "minizlib@1.0.4",
"_id": "minizlib@1.0.4",
"_inBundle": false,
"_integrity": "sha1-1cGr93vhVGGZUuJTM27Mq5sqMvU=",
"_integrity": "sha512-sN4U9tIJtBRwKbwgFh9qJfrPIQ/GGTRr1MGqkgOeMTLy8/lM0FcWU//FqlnZ3Vb7gJ+Mxh3FOg1EklibdajbaQ==",
"_location": "/tar/minizlib",
"_phantomChildren": {},
"_requested": {
"type": "range",
"type": "version",
"registry": true,
"raw": "minizlib@^1.0.3",
"raw": "minizlib@1.0.4",
"name": "minizlib",
"escapedName": "minizlib",
"rawSpec": "^1.0.3",
"rawSpec": "1.0.4",
"saveSpec": null,
"fetchSpec": "^1.0.3"
"fetchSpec": "1.0.4"
},
"_requiredBy": [
"/tar"
],
"_resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.0.3.tgz",
"_shasum": "d5c1abf77be154619952e253336eccab9b2a32f5",
"_spec": "minizlib@^1.0.3",
"_where": "/Users/rebecca/code/npm/node_modules/tar",
"_resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.0.4.tgz",
"_shasum": "8ebb51dd8bbe40b0126b5633dbb36b284a2f523c",
"_spec": "minizlib@1.0.4",
"_where": "/Users/rebecca/code/npm",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
@ -32,12 +32,12 @@
},
"bundleDependencies": false,
"dependencies": {
"minipass": "^2.0.0"
"minipass": "^2.2.1"
},
"deprecated": false,
"description": "A small fast zlib stream built on [minipass](http://npm.im/minipass) and Node.js's zlib binding.",
"devDependencies": {
"tap": "^10.3.0"
"tap": "^10.7.2"
},
"files": [
"index.js",
@ -67,5 +67,5 @@
"preversion": "npm test",
"test": "tap test/*.js --100 -J"
},
"version": "1.0.3"
"version": "1.0.4"
}