destroy
Advanced tools
Comparing version 1.1.0 to 1.1.1
27
index.js
/*! | ||
* destroy | ||
* Copyright(c) 2014 Jonathan Ong | ||
* Copyright(c) 2015-2022 Douglas Christopher Wilson | ||
* MIT Licensed | ||
@@ -77,2 +78,26 @@ */ | ||
/** | ||
* Close a Zlib stream. | ||
* | ||
* Zlib streams below Node.js 4.5.5 have a buggy implementation | ||
* of .close() when zlib encountered an error. | ||
* | ||
* @param {object} stream | ||
* @private | ||
*/ | ||
function closeZlibStream (stream) { | ||
if (stream._hadError === true) { | ||
var prop = stream._binding === null | ||
? '_binding' | ||
: '_handle' | ||
stream[prop] = { | ||
close: function () { this[prop] = null } | ||
} | ||
} | ||
stream.close() | ||
} | ||
/** | ||
* Destroy a Zlib stream. | ||
@@ -120,3 +145,3 @@ * | ||
// node.js < 8 fallback | ||
stream.close() | ||
closeZlibStream(stream) | ||
} | ||
@@ -123,0 +148,0 @@ |
{ | ||
"name": "destroy", | ||
"description": "destroy a stream if possible", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"author": { | ||
@@ -23,3 +23,3 @@ "name": "Jonathan Ong", | ||
"eslint-plugin-standard": "4.1.0", | ||
"mocha": "9.2.0", | ||
"mocha": "9.2.1", | ||
"nyc": "15.1.0" | ||
@@ -26,0 +26,0 @@ }, |
Sorry, the diff of this file is not supported yet
8176
144