11"use strict" ;
2+ var __createBinding = ( this && this . __createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
3+ if ( k2 === undefined ) k2 = k ;
4+ var desc = Object . getOwnPropertyDescriptor ( m , k ) ;
5+ if ( ! desc || ( "get" in desc ? ! m . __esModule : desc . writable || desc . configurable ) ) {
6+ desc = { enumerable : true , get : function ( ) { return m [ k ] ; } } ;
7+ }
8+ Object . defineProperty ( o , k2 , desc ) ;
9+ } ) : ( function ( o , m , k , k2 ) {
10+ if ( k2 === undefined ) k2 = k ;
11+ o [ k2 ] = m [ k ] ;
12+ } ) ) ;
13+ var __setModuleDefault = ( this && this . __setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
14+ Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
15+ } ) : function ( o , v ) {
16+ o [ "default" ] = v ;
17+ } ) ;
18+ var __importStar = ( this && this . __importStar ) || ( function ( ) {
19+ var ownKeys = function ( o ) {
20+ ownKeys = Object . getOwnPropertyNames || function ( o ) {
21+ var ar = [ ] ;
22+ for ( var k in o ) if ( Object . prototype . hasOwnProperty . call ( o , k ) ) ar [ ar . length ] = k ;
23+ return ar ;
24+ } ;
25+ return ownKeys ( o ) ;
26+ } ;
27+ return function ( mod ) {
28+ if ( mod && mod . __esModule ) return mod ;
29+ var result = { } ;
30+ if ( mod != null ) for ( var k = ownKeys ( mod ) , i = 0 ; i < k . length ; i ++ ) if ( k [ i ] !== "default" ) __createBinding ( result , mod , k [ i ] ) ;
31+ __setModuleDefault ( result , mod ) ;
32+ return result ;
33+ } ;
34+ } ) ( ) ;
235var __importDefault = ( this && this . __importDefault ) || function ( mod ) {
336 return ( mod && mod . __esModule ) ? mod : { "default" : mod } ;
437} ;
@@ -7,11 +40,18 @@ exports.BrotliDecompress = exports.BrotliCompress = exports.Brotli = exports.Unz
740const assert_1 = __importDefault ( require ( "assert" ) ) ;
841const buffer_1 = require ( "buffer" ) ;
942const minipass_1 = require ( "minipass" ) ;
10- const zlib_1 = __importDefault ( require ( "zlib" ) ) ;
43+ const realZlib = __importStar ( require ( "zlib" ) ) ;
1144const constants_js_1 = require ( "./constants.js" ) ;
1245var constants_js_2 = require ( "./constants.js" ) ;
1346Object . defineProperty ( exports , "constants" , { enumerable : true , get : function ( ) { return constants_js_2 . constants ; } } ) ;
1447const OriginalBufferConcat = buffer_1 . Buffer . concat ;
48+ const desc = Object . getOwnPropertyDescriptor ( buffer_1 . Buffer , 'concat' ) ;
49+ const noop = ( args ) => args ;
50+ const passthroughBufferConcat = desc ?. writable === true || desc ?. set !== undefined
51+ ? ( makeNoOp ) => {
52+ buffer_1 . Buffer . concat = makeNoOp ? noop : OriginalBufferConcat ;
53+ }
54+ : ( _ ) => { } ;
1555const _superWrite = Symbol ( '_superWrite' ) ;
1656class ZlibError extends Error {
1757 code ;
@@ -69,7 +109,7 @@ class ZlibBase extends minipass_1.Minipass {
69109 try {
70110 // @types /node doesn't know that it exports the classes, but they're there
71111 //@ts -ignore
72- this . #handle = new zlib_1 . default [ mode ] ( opts ) ;
112+ this . #handle = new realZlib [ mode ] ( opts ) ;
73113 }
74114 catch ( er ) {
75115 // make sure that all errors get decorated properly
@@ -159,20 +199,20 @@ class ZlibBase extends minipass_1.Minipass {
159199 this . #handle. close = ( ) => { } ;
160200 // It also calls `Buffer.concat()` at the end, which may be convenient
161201 // for some, but which we are not interested in as it slows us down.
162- buffer_1 . Buffer . concat = args => args ;
202+ passthroughBufferConcat ( true ) ;
163203 let result = undefined ;
164204 try {
165205 const flushFlag = typeof chunk [ _flushFlag ] === 'number'
166206 ? chunk [ _flushFlag ]
167207 : this . #flushFlag;
168208 result = this . #handle. _processChunk ( chunk , flushFlag ) ;
169209 // if we don't throw, reset it back how it was
170- buffer_1 . Buffer . concat = OriginalBufferConcat ;
210+ passthroughBufferConcat ( false ) ;
171211 }
172212 catch ( err ) {
173213 // or if we do, put Buffer.concat() back before we emit error
174214 // Error events call into user code, which may call Buffer.concat()
175- buffer_1 . Buffer . concat = OriginalBufferConcat ;
215+ passthroughBufferConcat ( false ) ;
176216 this . #onError( new ZlibError ( err ) ) ;
177217 }
178218 finally {
0 commit comments