extract-base-iterator 2.3.1 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/shared/EntryStream.d.cts +12 -31
- package/dist/cjs/shared/EntryStream.d.ts +12 -31
- package/dist/cjs/shared/EntryStream.js +29 -80
- package/dist/cjs/shared/EntryStream.js.map +1 -1
- package/dist/esm/shared/EntryStream.d.ts +12 -31
- package/dist/esm/shared/EntryStream.js +22 -80
- package/dist/esm/shared/EntryStream.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EntryStream - Simple readable
|
|
2
|
+
* EntryStream - Simple readable stream for entry content
|
|
3
3
|
*
|
|
4
|
-
* Extends
|
|
5
|
-
* Node 0.8 compatible.
|
|
4
|
+
* Extends Readable to emit 'data', 'end', 'error' events.
|
|
5
|
+
* Node 0.8 compatible via readable-stream polyfill.
|
|
6
6
|
*
|
|
7
7
|
* This base class is designed to be used by:
|
|
8
8
|
* - zip-iterator
|
|
@@ -10,46 +10,27 @@
|
|
|
10
10
|
* - tar-iterator
|
|
11
11
|
* - Any other archive iterator library
|
|
12
12
|
*/
|
|
13
|
-
import
|
|
13
|
+
import Stream from 'stream';
|
|
14
|
+
declare const ReadableBase: typeof Stream.Readable;
|
|
14
15
|
/**
|
|
15
16
|
* Base stream class for archive entry content.
|
|
16
17
|
* Can be extended for special entry types like sparse files.
|
|
17
18
|
*/
|
|
18
|
-
export default class EntryStream extends
|
|
19
|
-
protected _paused: boolean;
|
|
19
|
+
export default class EntryStream extends ReadableBase {
|
|
20
20
|
protected _ended: boolean;
|
|
21
|
-
|
|
22
|
-
protected _buffered: Buffer[];
|
|
21
|
+
constructor();
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
push(data: Buffer): void;
|
|
27
|
-
/**
|
|
28
|
-
* End the stream
|
|
23
|
+
* Signal end of stream by pushing null
|
|
29
24
|
*/
|
|
30
25
|
end(): void;
|
|
31
|
-
/**
|
|
32
|
-
* Resume reading (drain buffered data)
|
|
33
|
-
*/
|
|
34
|
-
resume(): this;
|
|
35
|
-
/**
|
|
36
|
-
* Pause reading
|
|
37
|
-
*/
|
|
38
|
-
pause(): this;
|
|
39
26
|
/**
|
|
40
27
|
* Check if stream has ended
|
|
41
28
|
*/
|
|
42
29
|
get ended(): boolean;
|
|
43
30
|
/**
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
pipe<T extends NodeJS.WritableStream>(dest: T): T;
|
|
47
|
-
/**
|
|
48
|
-
* Flush buffered data
|
|
49
|
-
*/
|
|
50
|
-
protected _flush(): void;
|
|
51
|
-
/**
|
|
52
|
-
* Emit end event (only once)
|
|
31
|
+
* Required by Readable - called when consumer wants data.
|
|
32
|
+
* Data is pushed externally via push(), nothing to do here.
|
|
53
33
|
*/
|
|
54
|
-
|
|
34
|
+
_read(_size: number): void;
|
|
55
35
|
}
|
|
36
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EntryStream - Simple readable
|
|
2
|
+
* EntryStream - Simple readable stream for entry content
|
|
3
3
|
*
|
|
4
|
-
* Extends
|
|
5
|
-
* Node 0.8 compatible.
|
|
4
|
+
* Extends Readable to emit 'data', 'end', 'error' events.
|
|
5
|
+
* Node 0.8 compatible via readable-stream polyfill.
|
|
6
6
|
*
|
|
7
7
|
* This base class is designed to be used by:
|
|
8
8
|
* - zip-iterator
|
|
@@ -10,46 +10,27 @@
|
|
|
10
10
|
* - tar-iterator
|
|
11
11
|
* - Any other archive iterator library
|
|
12
12
|
*/
|
|
13
|
-
import
|
|
13
|
+
import Stream from 'stream';
|
|
14
|
+
declare const ReadableBase: typeof Stream.Readable;
|
|
14
15
|
/**
|
|
15
16
|
* Base stream class for archive entry content.
|
|
16
17
|
* Can be extended for special entry types like sparse files.
|
|
17
18
|
*/
|
|
18
|
-
export default class EntryStream extends
|
|
19
|
-
protected _paused: boolean;
|
|
19
|
+
export default class EntryStream extends ReadableBase {
|
|
20
20
|
protected _ended: boolean;
|
|
21
|
-
|
|
22
|
-
protected _buffered: Buffer[];
|
|
21
|
+
constructor();
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
push(data: Buffer): void;
|
|
27
|
-
/**
|
|
28
|
-
* End the stream
|
|
23
|
+
* Signal end of stream by pushing null
|
|
29
24
|
*/
|
|
30
25
|
end(): void;
|
|
31
|
-
/**
|
|
32
|
-
* Resume reading (drain buffered data)
|
|
33
|
-
*/
|
|
34
|
-
resume(): this;
|
|
35
|
-
/**
|
|
36
|
-
* Pause reading
|
|
37
|
-
*/
|
|
38
|
-
pause(): this;
|
|
39
26
|
/**
|
|
40
27
|
* Check if stream has ended
|
|
41
28
|
*/
|
|
42
29
|
get ended(): boolean;
|
|
43
30
|
/**
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
pipe<T extends NodeJS.WritableStream>(dest: T): T;
|
|
47
|
-
/**
|
|
48
|
-
* Flush buffered data
|
|
49
|
-
*/
|
|
50
|
-
protected _flush(): void;
|
|
51
|
-
/**
|
|
52
|
-
* Emit end event (only once)
|
|
31
|
+
* Required by Readable - called when consumer wants data.
|
|
32
|
+
* Data is pushed externally via push(), nothing to do here.
|
|
53
33
|
*/
|
|
54
|
-
|
|
34
|
+
_read(_size: number): void;
|
|
55
35
|
}
|
|
36
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EntryStream - Simple readable
|
|
2
|
+
* EntryStream - Simple readable stream for entry content
|
|
3
3
|
*
|
|
4
|
-
* Extends
|
|
5
|
-
* Node 0.8 compatible.
|
|
4
|
+
* Extends Readable to emit 'data', 'end', 'error' events.
|
|
5
|
+
* Node 0.8 compatible via readable-stream polyfill.
|
|
6
6
|
*
|
|
7
7
|
* This base class is designed to be used by:
|
|
8
8
|
* - zip-iterator
|
|
@@ -19,7 +19,8 @@ Object.defineProperty(exports, "default", {
|
|
|
19
19
|
return EntryStream;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
var
|
|
22
|
+
var _readablestream = /*#__PURE__*/ _interop_require_default(require("readable-stream"));
|
|
23
|
+
var _stream = /*#__PURE__*/ _interop_require_default(require("stream"));
|
|
23
24
|
function _assert_this_initialized(self) {
|
|
24
25
|
if (self === void 0) {
|
|
25
26
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
@@ -68,6 +69,11 @@ function _inherits(subClass, superClass) {
|
|
|
68
69
|
});
|
|
69
70
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
70
71
|
}
|
|
72
|
+
function _interop_require_default(obj) {
|
|
73
|
+
return obj && obj.__esModule ? obj : {
|
|
74
|
+
default: obj
|
|
75
|
+
};
|
|
76
|
+
}
|
|
71
77
|
function _possible_constructor_return(self, call) {
|
|
72
78
|
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
73
79
|
return call;
|
|
@@ -93,94 +99,37 @@ function _is_native_reflect_construct() {
|
|
|
93
99
|
return !!result;
|
|
94
100
|
})();
|
|
95
101
|
}
|
|
96
|
-
|
|
102
|
+
// Use native streams when available, readable-stream only for Node 0.x
|
|
103
|
+
var major = +process.versions.node.split('.')[0];
|
|
104
|
+
var ReadableBase = major > 0 ? _stream.default.Readable : _readablestream.default.Readable;
|
|
105
|
+
var EntryStream = /*#__PURE__*/ function(ReadableBase) {
|
|
97
106
|
"use strict";
|
|
98
|
-
_inherits(EntryStream,
|
|
107
|
+
_inherits(EntryStream, ReadableBase);
|
|
99
108
|
function EntryStream() {
|
|
100
109
|
_class_call_check(this, EntryStream);
|
|
101
110
|
var _this;
|
|
102
|
-
|
|
111
|
+
// Use a large highWaterMark since data is pushed externally (not from _read)
|
|
112
|
+
// This prevents backpressure issues when pushing synchronously
|
|
113
|
+
_this = _call_super(this, EntryStream, [
|
|
114
|
+
{
|
|
115
|
+
highWaterMark: 1024 * 1024
|
|
116
|
+
}
|
|
117
|
+
]), _this._ended = false; // 1MB buffer
|
|
103
118
|
return _this;
|
|
104
119
|
}
|
|
105
120
|
var _proto = EntryStream.prototype;
|
|
106
121
|
/**
|
|
107
|
-
*
|
|
108
|
-
*/ _proto.push = function push(data) {
|
|
109
|
-
if (this._ended) return;
|
|
110
|
-
if (this._paused) {
|
|
111
|
-
this._buffered.push(data);
|
|
112
|
-
} else {
|
|
113
|
-
this.emit('data', data);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* End the stream
|
|
122
|
+
* Signal end of stream by pushing null
|
|
118
123
|
*/ _proto.end = function end() {
|
|
119
124
|
if (this._ended) return;
|
|
120
125
|
this._ended = true;
|
|
121
|
-
|
|
122
|
-
if (!this._paused) {
|
|
123
|
-
this._flush();
|
|
124
|
-
this._emitEnd();
|
|
125
|
-
}
|
|
126
|
-
// Otherwise, end will be emitted when resume() is called
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Resume reading (drain buffered data)
|
|
130
|
-
*/ _proto.resume = function resume() {
|
|
131
|
-
if (!this._paused) return this;
|
|
132
|
-
this._paused = false;
|
|
133
|
-
this._flush();
|
|
134
|
-
// If stream was ended while paused, emit end now
|
|
135
|
-
if (this._ended && !this._endEmitted) {
|
|
136
|
-
this._emitEnd();
|
|
137
|
-
}
|
|
138
|
-
return this;
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* Pause reading
|
|
142
|
-
*/ _proto.pause = function pause() {
|
|
143
|
-
this._paused = true;
|
|
144
|
-
return this;
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* Pipe to a writable stream
|
|
148
|
-
*/ _proto.pipe = function pipe(dest) {
|
|
149
|
-
var self = this;
|
|
150
|
-
// Cast to EventEmitter-compatible type for backpressure handling
|
|
151
|
-
var emitter = dest;
|
|
152
|
-
this.on('data', function onData(chunk) {
|
|
153
|
-
var canContinue = dest.write(chunk);
|
|
154
|
-
// Handle backpressure if dest returns false
|
|
155
|
-
if (canContinue === false && typeof emitter.once === 'function') {
|
|
156
|
-
self.pause();
|
|
157
|
-
emitter.once('drain', function onDrain() {
|
|
158
|
-
self.resume();
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
this.on('end', function onEnd() {
|
|
163
|
-
if (typeof dest.end === 'function') {
|
|
164
|
-
dest.end();
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
this.resume();
|
|
168
|
-
return dest;
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* Flush buffered data
|
|
172
|
-
*/ _proto._flush = function _flush() {
|
|
173
|
-
while(this._buffered.length > 0){
|
|
174
|
-
var chunk = this._buffered.shift();
|
|
175
|
-
this.emit('data', chunk);
|
|
176
|
-
}
|
|
126
|
+
this.push(null);
|
|
177
127
|
};
|
|
178
128
|
/**
|
|
179
|
-
*
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
this.emit('end');
|
|
129
|
+
* Required by Readable - called when consumer wants data.
|
|
130
|
+
* Data is pushed externally via push(), nothing to do here.
|
|
131
|
+
*/ _proto._read = function _read(_size) {
|
|
132
|
+
// Data is pushed externally, nothing to do here
|
|
184
133
|
};
|
|
185
134
|
_create_class(EntryStream, [
|
|
186
135
|
{
|
|
@@ -193,5 +142,5 @@ var EntryStream = /*#__PURE__*/ function(EventEmitter) {
|
|
|
193
142
|
}
|
|
194
143
|
]);
|
|
195
144
|
return EntryStream;
|
|
196
|
-
}(
|
|
145
|
+
}(ReadableBase);
|
|
197
146
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/EntryStream.ts"],"sourcesContent":["/**\n * EntryStream - Simple readable
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/EntryStream.ts"],"sourcesContent":["/**\n * EntryStream - Simple readable stream for entry content\n *\n * Extends Readable to emit 'data', 'end', 'error' events.\n * Node 0.8 compatible via readable-stream polyfill.\n *\n * This base class is designed to be used by:\n * - zip-iterator\n * - 7z-iterator\n * - tar-iterator\n * - Any other archive iterator library\n */\n\nimport StreamCompat from 'readable-stream';\nimport Stream from 'stream';\n\n// Use native streams when available, readable-stream only for Node 0.x\nconst major = +process.versions.node.split('.')[0];\nconst ReadableBase: typeof Stream.Readable = major > 0 ? Stream.Readable : (StreamCompat.Readable as typeof Stream.Readable);\n\n/**\n * Base stream class for archive entry content.\n * Can be extended for special entry types like sparse files.\n */\nexport default class EntryStream extends ReadableBase {\n protected _ended = false;\n\n constructor() {\n // Use a large highWaterMark since data is pushed externally (not from _read)\n // This prevents backpressure issues when pushing synchronously\n super({ highWaterMark: 1024 * 1024 }); // 1MB buffer\n }\n\n /**\n * Signal end of stream by pushing null\n */\n end(): void {\n if (this._ended) return;\n this._ended = true;\n this.push(null);\n }\n\n /**\n * Check if stream has ended\n */\n get ended(): boolean {\n return this._ended;\n }\n\n /**\n * Required by Readable - called when consumer wants data.\n * Data is pushed externally via push(), nothing to do here.\n */\n _read(_size: number): void {\n // Data is pushed externally, nothing to do here\n }\n}\n"],"names":["EntryStream","major","process","versions","node","split","ReadableBase","Stream","Readable","StreamCompat","highWaterMark","_ended","end","push","_read","_size","ended"],"mappings":"AAAA;;;;;;;;;;;CAWC;;;;;;;eAaoBA;;;qEAXI;6DACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnB,uEAAuE;AACvE,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,eAAuCL,QAAQ,IAAIM,eAAM,CAACC,QAAQ,GAAIC,uBAAY,CAACD,QAAQ;AAMlF,IAAA,AAAMR,4BAAN;;cAAMA;aAAAA;gCAAAA;;QAIjB,6EAA6E;QAC7E,+DAA+D;gBAC/D,kBANiBA;YAMX;gBAAEU,eAAe,OAAO;YAAK;kBAL3BC,SAAS,OAKsB,aAAa;;;iBANnCX;IASnB;;GAEC,GACDY,OAAAA,GAIC,GAJDA,SAAAA;QACE,IAAI,IAAI,CAACD,MAAM,EAAE;QACjB,IAAI,CAACA,MAAM,GAAG;QACd,IAAI,CAACE,IAAI,CAAC;IACZ;IASA;;;GAGC,GACDC,OAAAA,KAEC,GAFDA,SAAAA,MAAMC,KAAa;IACjB,gDAAgD;IAClD;kBA/BmBf;;YAqBfgB,KAAAA;iBAAJ,AAHA;;GAEC,GACD;gBACE,OAAO,IAAI,CAACL,MAAM;YACpB;;;WAvBmBX;EAAoBM"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EntryStream - Simple readable
|
|
2
|
+
* EntryStream - Simple readable stream for entry content
|
|
3
3
|
*
|
|
4
|
-
* Extends
|
|
5
|
-
* Node 0.8 compatible.
|
|
4
|
+
* Extends Readable to emit 'data', 'end', 'error' events.
|
|
5
|
+
* Node 0.8 compatible via readable-stream polyfill.
|
|
6
6
|
*
|
|
7
7
|
* This base class is designed to be used by:
|
|
8
8
|
* - zip-iterator
|
|
@@ -10,46 +10,27 @@
|
|
|
10
10
|
* - tar-iterator
|
|
11
11
|
* - Any other archive iterator library
|
|
12
12
|
*/
|
|
13
|
-
import
|
|
13
|
+
import Stream from 'stream';
|
|
14
|
+
declare const ReadableBase: typeof Stream.Readable;
|
|
14
15
|
/**
|
|
15
16
|
* Base stream class for archive entry content.
|
|
16
17
|
* Can be extended for special entry types like sparse files.
|
|
17
18
|
*/
|
|
18
|
-
export default class EntryStream extends
|
|
19
|
-
protected _paused: boolean;
|
|
19
|
+
export default class EntryStream extends ReadableBase {
|
|
20
20
|
protected _ended: boolean;
|
|
21
|
-
|
|
22
|
-
protected _buffered: Buffer[];
|
|
21
|
+
constructor();
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
push(data: Buffer): void;
|
|
27
|
-
/**
|
|
28
|
-
* End the stream
|
|
23
|
+
* Signal end of stream by pushing null
|
|
29
24
|
*/
|
|
30
25
|
end(): void;
|
|
31
|
-
/**
|
|
32
|
-
* Resume reading (drain buffered data)
|
|
33
|
-
*/
|
|
34
|
-
resume(): this;
|
|
35
|
-
/**
|
|
36
|
-
* Pause reading
|
|
37
|
-
*/
|
|
38
|
-
pause(): this;
|
|
39
26
|
/**
|
|
40
27
|
* Check if stream has ended
|
|
41
28
|
*/
|
|
42
29
|
get ended(): boolean;
|
|
43
30
|
/**
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
pipe<T extends NodeJS.WritableStream>(dest: T): T;
|
|
47
|
-
/**
|
|
48
|
-
* Flush buffered data
|
|
49
|
-
*/
|
|
50
|
-
protected _flush(): void;
|
|
51
|
-
/**
|
|
52
|
-
* Emit end event (only once)
|
|
31
|
+
* Required by Readable - called when consumer wants data.
|
|
32
|
+
* Data is pushed externally via push(), nothing to do here.
|
|
53
33
|
*/
|
|
54
|
-
|
|
34
|
+
_read(_size: number): void;
|
|
55
35
|
}
|
|
36
|
+
export {};
|
|
@@ -1,55 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EntryStream - Simple readable
|
|
2
|
+
* EntryStream - Simple readable stream for entry content
|
|
3
3
|
*
|
|
4
|
-
* Extends
|
|
5
|
-
* Node 0.8 compatible.
|
|
4
|
+
* Extends Readable to emit 'data', 'end', 'error' events.
|
|
5
|
+
* Node 0.8 compatible via readable-stream polyfill.
|
|
6
6
|
*
|
|
7
7
|
* This base class is designed to be used by:
|
|
8
8
|
* - zip-iterator
|
|
9
9
|
* - 7z-iterator
|
|
10
10
|
* - tar-iterator
|
|
11
11
|
* - Any other archive iterator library
|
|
12
|
-
*/ import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} else {
|
|
21
|
-
this.emit('data', data);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* End the stream
|
|
12
|
+
*/ import StreamCompat from 'readable-stream';
|
|
13
|
+
import Stream from 'stream';
|
|
14
|
+
// Use native streams when available, readable-stream only for Node 0.x
|
|
15
|
+
const major = +process.versions.node.split('.')[0];
|
|
16
|
+
const ReadableBase = major > 0 ? Stream.Readable : StreamCompat.Readable;
|
|
17
|
+
let EntryStream = class EntryStream extends ReadableBase {
|
|
18
|
+
/**
|
|
19
|
+
* Signal end of stream by pushing null
|
|
26
20
|
*/ end() {
|
|
27
21
|
if (this._ended) return;
|
|
28
22
|
this._ended = true;
|
|
29
|
-
|
|
30
|
-
if (!this._paused) {
|
|
31
|
-
this._flush();
|
|
32
|
-
this._emitEnd();
|
|
33
|
-
}
|
|
34
|
-
// Otherwise, end will be emitted when resume() is called
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Resume reading (drain buffered data)
|
|
38
|
-
*/ resume() {
|
|
39
|
-
if (!this._paused) return this;
|
|
40
|
-
this._paused = false;
|
|
41
|
-
this._flush();
|
|
42
|
-
// If stream was ended while paused, emit end now
|
|
43
|
-
if (this._ended && !this._endEmitted) {
|
|
44
|
-
this._emitEnd();
|
|
45
|
-
}
|
|
46
|
-
return this;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Pause reading
|
|
50
|
-
*/ pause() {
|
|
51
|
-
this._paused = true;
|
|
52
|
-
return this;
|
|
23
|
+
this.push(null);
|
|
53
24
|
}
|
|
54
25
|
/**
|
|
55
26
|
* Check if stream has ended
|
|
@@ -57,46 +28,17 @@ let EntryStream = class EntryStream extends EventEmitter {
|
|
|
57
28
|
return this._ended;
|
|
58
29
|
}
|
|
59
30
|
/**
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var emitter = dest;
|
|
65
|
-
this.on('data', function onData(chunk) {
|
|
66
|
-
var canContinue = dest.write(chunk);
|
|
67
|
-
// Handle backpressure if dest returns false
|
|
68
|
-
if (canContinue === false && typeof emitter.once === 'function') {
|
|
69
|
-
self.pause();
|
|
70
|
-
emitter.once('drain', function onDrain() {
|
|
71
|
-
self.resume();
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
this.on('end', function onEnd() {
|
|
76
|
-
if (typeof dest.end === 'function') {
|
|
77
|
-
dest.end();
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
this.resume();
|
|
81
|
-
return dest;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Flush buffered data
|
|
85
|
-
*/ _flush() {
|
|
86
|
-
while(this._buffered.length > 0){
|
|
87
|
-
var chunk = this._buffered.shift();
|
|
88
|
-
this.emit('data', chunk);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Emit end event (only once)
|
|
93
|
-
*/ _emitEnd() {
|
|
94
|
-
if (this._endEmitted) return;
|
|
95
|
-
this._endEmitted = true;
|
|
96
|
-
this.emit('end');
|
|
31
|
+
* Required by Readable - called when consumer wants data.
|
|
32
|
+
* Data is pushed externally via push(), nothing to do here.
|
|
33
|
+
*/ _read(_size) {
|
|
34
|
+
// Data is pushed externally, nothing to do here
|
|
97
35
|
}
|
|
98
|
-
constructor(
|
|
99
|
-
|
|
36
|
+
constructor(){
|
|
37
|
+
// Use a large highWaterMark since data is pushed externally (not from _read)
|
|
38
|
+
// This prevents backpressure issues when pushing synchronously
|
|
39
|
+
super({
|
|
40
|
+
highWaterMark: 1024 * 1024
|
|
41
|
+
}), this._ended = false; // 1MB buffer
|
|
100
42
|
}
|
|
101
43
|
};
|
|
102
44
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/EntryStream.ts"],"sourcesContent":["/**\n * EntryStream - Simple readable
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/EntryStream.ts"],"sourcesContent":["/**\n * EntryStream - Simple readable stream for entry content\n *\n * Extends Readable to emit 'data', 'end', 'error' events.\n * Node 0.8 compatible via readable-stream polyfill.\n *\n * This base class is designed to be used by:\n * - zip-iterator\n * - 7z-iterator\n * - tar-iterator\n * - Any other archive iterator library\n */\n\nimport StreamCompat from 'readable-stream';\nimport Stream from 'stream';\n\n// Use native streams when available, readable-stream only for Node 0.x\nconst major = +process.versions.node.split('.')[0];\nconst ReadableBase: typeof Stream.Readable = major > 0 ? Stream.Readable : (StreamCompat.Readable as typeof Stream.Readable);\n\n/**\n * Base stream class for archive entry content.\n * Can be extended for special entry types like sparse files.\n */\nexport default class EntryStream extends ReadableBase {\n protected _ended = false;\n\n constructor() {\n // Use a large highWaterMark since data is pushed externally (not from _read)\n // This prevents backpressure issues when pushing synchronously\n super({ highWaterMark: 1024 * 1024 }); // 1MB buffer\n }\n\n /**\n * Signal end of stream by pushing null\n */\n end(): void {\n if (this._ended) return;\n this._ended = true;\n this.push(null);\n }\n\n /**\n * Check if stream has ended\n */\n get ended(): boolean {\n return this._ended;\n }\n\n /**\n * Required by Readable - called when consumer wants data.\n * Data is pushed externally via push(), nothing to do here.\n */\n _read(_size: number): void {\n // Data is pushed externally, nothing to do here\n }\n}\n"],"names":["StreamCompat","Stream","major","process","versions","node","split","ReadableBase","Readable","EntryStream","end","_ended","push","ended","_read","_size","highWaterMark"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,OAAOA,kBAAkB,kBAAkB;AAC3C,OAAOC,YAAY,SAAS;AAE5B,uEAAuE;AACvE,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,eAAuCL,QAAQ,IAAID,OAAOO,QAAQ,GAAIR,aAAaQ,QAAQ;AAMlF,IAAA,AAAMC,cAAN,MAAMA,oBAAoBF;IASvC;;GAEC,GACDG,MAAY;QACV,IAAI,IAAI,CAACC,MAAM,EAAE;QACjB,IAAI,CAACA,MAAM,GAAG;QACd,IAAI,CAACC,IAAI,CAAC;IACZ;IAEA;;GAEC,GACD,IAAIC,QAAiB;QACnB,OAAO,IAAI,CAACF,MAAM;IACpB;IAEA;;;GAGC,GACDG,MAAMC,KAAa,EAAQ;IACzB,gDAAgD;IAClD;IA5BA,aAAc;QACZ,6EAA6E;QAC7E,+DAA+D;QAC/D,KAAK,CAAC;YAAEC,eAAe,OAAO;QAAK,SAL3BL,SAAS,OAKsB,aAAa;IACtD;AAyBF;AApCA;;;CAGC,GACD,SAAqBF,yBAgCpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extract-base-iterator",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.3",
|
|
4
4
|
"description": "Base iterator for extract iterators like tar-iterator and zip-iterator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"extract",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"next-tick": "*",
|
|
50
50
|
"object-assign": "*",
|
|
51
51
|
"queue-cb": "*",
|
|
52
|
+
"readable-stream": "^2.3.8",
|
|
52
53
|
"rimraf2": "*",
|
|
53
54
|
"stack-base-iterator": "*"
|
|
54
55
|
},
|