extract-base-iterator 2.3.0 → 2.3.1

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.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * EntryStream - Simple readable-like stream for entry content
3
+ *
4
+ * Extends EventEmitter to emit 'data', 'end', 'error' events.
5
+ * Node 0.8 compatible.
6
+ *
7
+ * This base class is designed to be used by:
8
+ * - zip-iterator
9
+ * - 7z-iterator
10
+ * - tar-iterator
11
+ * - Any other archive iterator library
12
+ */
13
+ import { EventEmitter } from 'events';
14
+ /**
15
+ * Base stream class for archive entry content.
16
+ * Can be extended for special entry types like sparse files.
17
+ */
18
+ export default class EntryStream extends EventEmitter {
19
+ protected _paused: boolean;
20
+ protected _ended: boolean;
21
+ protected _endEmitted: boolean;
22
+ protected _buffered: Buffer[];
23
+ /**
24
+ * Push data to the stream
25
+ */
26
+ push(data: Buffer): void;
27
+ /**
28
+ * End the stream
29
+ */
30
+ end(): void;
31
+ /**
32
+ * Resume reading (drain buffered data)
33
+ */
34
+ resume(): this;
35
+ /**
36
+ * Pause reading
37
+ */
38
+ pause(): this;
39
+ /**
40
+ * Check if stream has ended
41
+ */
42
+ get ended(): boolean;
43
+ /**
44
+ * Pipe to a writable stream
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)
53
+ */
54
+ protected _emitEnd(): void;
55
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * EntryStream - Simple readable-like stream for entry content
3
+ *
4
+ * Extends EventEmitter to emit 'data', 'end', 'error' events.
5
+ * Node 0.8 compatible.
6
+ *
7
+ * This base class is designed to be used by:
8
+ * - zip-iterator
9
+ * - 7z-iterator
10
+ * - tar-iterator
11
+ * - Any other archive iterator library
12
+ */
13
+ import { EventEmitter } from 'events';
14
+ /**
15
+ * Base stream class for archive entry content.
16
+ * Can be extended for special entry types like sparse files.
17
+ */
18
+ export default class EntryStream extends EventEmitter {
19
+ protected _paused: boolean;
20
+ protected _ended: boolean;
21
+ protected _endEmitted: boolean;
22
+ protected _buffered: Buffer[];
23
+ /**
24
+ * Push data to the stream
25
+ */
26
+ push(data: Buffer): void;
27
+ /**
28
+ * End the stream
29
+ */
30
+ end(): void;
31
+ /**
32
+ * Resume reading (drain buffered data)
33
+ */
34
+ resume(): this;
35
+ /**
36
+ * Pause reading
37
+ */
38
+ pause(): this;
39
+ /**
40
+ * Check if stream has ended
41
+ */
42
+ get ended(): boolean;
43
+ /**
44
+ * Pipe to a writable stream
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)
53
+ */
54
+ protected _emitEnd(): void;
55
+ }
@@ -0,0 +1,197 @@
1
+ /**
2
+ * EntryStream - Simple readable-like stream for entry content
3
+ *
4
+ * Extends EventEmitter to emit 'data', 'end', 'error' events.
5
+ * Node 0.8 compatible.
6
+ *
7
+ * This base class is designed to be used by:
8
+ * - zip-iterator
9
+ * - 7z-iterator
10
+ * - tar-iterator
11
+ * - Any other archive iterator library
12
+ */ "use strict";
13
+ Object.defineProperty(exports, "__esModule", {
14
+ value: true
15
+ });
16
+ Object.defineProperty(exports, "default", {
17
+ enumerable: true,
18
+ get: function() {
19
+ return EntryStream;
20
+ }
21
+ });
22
+ var _events = require("events");
23
+ function _assert_this_initialized(self) {
24
+ if (self === void 0) {
25
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
26
+ }
27
+ return self;
28
+ }
29
+ function _call_super(_this, derived, args) {
30
+ derived = _get_prototype_of(derived);
31
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
32
+ }
33
+ function _class_call_check(instance, Constructor) {
34
+ if (!(instance instanceof Constructor)) {
35
+ throw new TypeError("Cannot call a class as a function");
36
+ }
37
+ }
38
+ function _defineProperties(target, props) {
39
+ for(var i = 0; i < props.length; i++){
40
+ var descriptor = props[i];
41
+ descriptor.enumerable = descriptor.enumerable || false;
42
+ descriptor.configurable = true;
43
+ if ("value" in descriptor) descriptor.writable = true;
44
+ Object.defineProperty(target, descriptor.key, descriptor);
45
+ }
46
+ }
47
+ function _create_class(Constructor, protoProps, staticProps) {
48
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
49
+ if (staticProps) _defineProperties(Constructor, staticProps);
50
+ return Constructor;
51
+ }
52
+ function _get_prototype_of(o) {
53
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
54
+ return o.__proto__ || Object.getPrototypeOf(o);
55
+ };
56
+ return _get_prototype_of(o);
57
+ }
58
+ function _inherits(subClass, superClass) {
59
+ if (typeof superClass !== "function" && superClass !== null) {
60
+ throw new TypeError("Super expression must either be null or a function");
61
+ }
62
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
63
+ constructor: {
64
+ value: subClass,
65
+ writable: true,
66
+ configurable: true
67
+ }
68
+ });
69
+ if (superClass) _set_prototype_of(subClass, superClass);
70
+ }
71
+ function _possible_constructor_return(self, call) {
72
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
73
+ return call;
74
+ }
75
+ return _assert_this_initialized(self);
76
+ }
77
+ function _set_prototype_of(o, p) {
78
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
79
+ o.__proto__ = p;
80
+ return o;
81
+ };
82
+ return _set_prototype_of(o, p);
83
+ }
84
+ function _type_of(obj) {
85
+ "@swc/helpers - typeof";
86
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
87
+ }
88
+ function _is_native_reflect_construct() {
89
+ try {
90
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
91
+ } catch (_) {}
92
+ return (_is_native_reflect_construct = function() {
93
+ return !!result;
94
+ })();
95
+ }
96
+ var EntryStream = /*#__PURE__*/ function(EventEmitter) {
97
+ "use strict";
98
+ _inherits(EntryStream, EventEmitter);
99
+ function EntryStream() {
100
+ _class_call_check(this, EntryStream);
101
+ var _this;
102
+ _this = _call_super(this, EntryStream, arguments), _this._paused = true, _this._ended = false, _this._endEmitted = false, _this._buffered = [];
103
+ return _this;
104
+ }
105
+ var _proto = EntryStream.prototype;
106
+ /**
107
+ * Push data to the stream
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
118
+ */ _proto.end = function end() {
119
+ if (this._ended) return;
120
+ this._ended = true;
121
+ // If not paused, flush and emit end now
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
+ }
177
+ };
178
+ /**
179
+ * Emit end event (only once)
180
+ */ _proto._emitEnd = function _emitEnd() {
181
+ if (this._endEmitted) return;
182
+ this._endEmitted = true;
183
+ this.emit('end');
184
+ };
185
+ _create_class(EntryStream, [
186
+ {
187
+ key: "ended",
188
+ get: /**
189
+ * Check if stream has ended
190
+ */ function get() {
191
+ return this._ended;
192
+ }
193
+ }
194
+ ]);
195
+ return EntryStream;
196
+ }(_events.EventEmitter);
197
+ /* 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; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/EntryStream.ts"],"sourcesContent":["/**\n * EntryStream - Simple readable-like stream for entry content\n *\n * Extends EventEmitter to emit 'data', 'end', 'error' events.\n * Node 0.8 compatible.\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 { EventEmitter } from 'events';\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 EventEmitter {\n protected _paused = true;\n protected _ended = false;\n protected _endEmitted = false;\n protected _buffered: Buffer[] = [];\n\n /**\n * Push data to the stream\n */\n push(data: Buffer): void {\n if (this._ended) return;\n\n if (this._paused) {\n this._buffered.push(data);\n } else {\n this.emit('data', data);\n }\n }\n\n /**\n * End the stream\n */\n end(): void {\n if (this._ended) return;\n this._ended = true;\n\n // If not paused, flush and emit end now\n if (!this._paused) {\n this._flush();\n this._emitEnd();\n }\n // Otherwise, end will be emitted when resume() is called\n }\n\n /**\n * Resume reading (drain buffered data)\n */\n resume(): this {\n if (!this._paused) return this;\n this._paused = false;\n this._flush();\n // If stream was ended while paused, emit end now\n if (this._ended && !this._endEmitted) {\n this._emitEnd();\n }\n return this;\n }\n\n /**\n * Pause reading\n */\n pause(): this {\n this._paused = true;\n return this;\n }\n\n /**\n * Check if stream has ended\n */\n get ended(): boolean {\n return this._ended;\n }\n\n /**\n * Pipe to a writable stream\n */\n pipe<T extends NodeJS.WritableStream>(dest: T): T {\n var self = this;\n // Cast to EventEmitter-compatible type for backpressure handling\n var emitter = dest as T & { once?: (event: string, fn: () => void) => void };\n this.on('data', function onData(chunk: Buffer) {\n var canContinue = dest.write(chunk);\n // Handle backpressure if dest returns false\n if (canContinue === false && typeof emitter.once === 'function') {\n self.pause();\n emitter.once('drain', function onDrain() {\n self.resume();\n });\n }\n });\n\n this.on('end', function onEnd() {\n if (typeof dest.end === 'function') {\n dest.end();\n }\n });\n\n this.resume();\n return dest;\n }\n\n /**\n * Flush buffered data\n */\n protected _flush(): void {\n while (this._buffered.length > 0) {\n var chunk = this._buffered.shift();\n this.emit('data', chunk);\n }\n }\n\n /**\n * Emit end event (only once)\n */\n protected _emitEnd(): void {\n if (this._endEmitted) return;\n this._endEmitted = true;\n this.emit('end');\n }\n}\n"],"names":["EntryStream","_paused","_ended","_endEmitted","_buffered","push","data","emit","end","_flush","_emitEnd","resume","pause","pipe","dest","self","emitter","on","onData","chunk","canContinue","write","once","onDrain","onEnd","length","shift","ended","EventEmitter"],"mappings":"AAAA;;;;;;;;;;;CAWC;;;;;;;eAQoBA;;;sBANQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMd,IAAA,AAAMA,4BAAN;;cAAMA;aAAAA;gCAAAA;;gBAAN,kBAAMA,+BACTC,UAAU,YACVC,SAAS,aACTC,cAAc,aACdC,YAAsB,EAAE;;;iBAJfJ;IAMnB;;GAEC,GACDK,OAAAA,IAQC,GARDA,SAAAA,KAAKC,IAAY;QACf,IAAI,IAAI,CAACJ,MAAM,EAAE;QAEjB,IAAI,IAAI,CAACD,OAAO,EAAE;YAChB,IAAI,CAACG,SAAS,CAACC,IAAI,CAACC;QACtB,OAAO;YACL,IAAI,CAACC,IAAI,CAAC,QAAQD;QACpB;IACF;IAEA;;GAEC,GACDE,OAAAA,GAUC,GAVDA,SAAAA;QACE,IAAI,IAAI,CAACN,MAAM,EAAE;QACjB,IAAI,CAACA,MAAM,GAAG;QAEd,wCAAwC;QACxC,IAAI,CAAC,IAAI,CAACD,OAAO,EAAE;YACjB,IAAI,CAACQ,MAAM;YACX,IAAI,CAACC,QAAQ;QACf;IACA,yDAAyD;IAC3D;IAEA;;GAEC,GACDC,OAAAA,MASC,GATDA,SAAAA;QACE,IAAI,CAAC,IAAI,CAACV,OAAO,EAAE,OAAO,IAAI;QAC9B,IAAI,CAACA,OAAO,GAAG;QACf,IAAI,CAACQ,MAAM;QACX,iDAAiD;QACjD,IAAI,IAAI,CAACP,MAAM,IAAI,CAAC,IAAI,CAACC,WAAW,EAAE;YACpC,IAAI,CAACO,QAAQ;QACf;QACA,OAAO,IAAI;IACb;IAEA;;GAEC,GACDE,OAAAA,KAGC,GAHDA,SAAAA;QACE,IAAI,CAACX,OAAO,GAAG;QACf,OAAO,IAAI;IACb;IASA;;GAEC,GACDY,OAAAA,IAuBC,GAvBDA,SAAAA,KAAsCC,IAAO;QAC3C,IAAIC,OAAO,IAAI;QACf,iEAAiE;QACjE,IAAIC,UAAUF;QACd,IAAI,CAACG,EAAE,CAAC,QAAQ,SAASC,OAAOC,KAAa;YAC3C,IAAIC,cAAcN,KAAKO,KAAK,CAACF;YAC7B,4CAA4C;YAC5C,IAAIC,gBAAgB,SAAS,OAAOJ,QAAQM,IAAI,KAAK,YAAY;gBAC/DP,KAAKH,KAAK;gBACVI,QAAQM,IAAI,CAAC,SAAS,SAASC;oBAC7BR,KAAKJ,MAAM;gBACb;YACF;QACF;QAEA,IAAI,CAACM,EAAE,CAAC,OAAO,SAASO;YACtB,IAAI,OAAOV,KAAKN,GAAG,KAAK,YAAY;gBAClCM,KAAKN,GAAG;YACV;QACF;QAEA,IAAI,CAACG,MAAM;QACX,OAAOG;IACT;IAEA;;GAEC,GACD,OAAUL,MAKT,GALD,SAAUA;QACR,MAAO,IAAI,CAACL,SAAS,CAACqB,MAAM,GAAG,EAAG;YAChC,IAAIN,QAAQ,IAAI,CAACf,SAAS,CAACsB,KAAK;YAChC,IAAI,CAACnB,IAAI,CAAC,QAAQY;QACpB;IACF;IAEA;;GAEC,GACD,OAAUT,QAIT,GAJD,SAAUA;QACR,IAAI,IAAI,CAACP,WAAW,EAAE;QACtB,IAAI,CAACA,WAAW,GAAG;QACnB,IAAI,CAACI,IAAI,CAAC;IACZ;kBA5GmBP;;YA2Df2B,KAAAA;iBAAJ,AAHA;;GAEC,GACD;gBACE,OAAO,IAAI,CAACzB,MAAM;YACpB;;;WA7DmBF;EAAoB4B,oBAAY"}
@@ -11,3 +11,4 @@
11
11
  */
12
12
  export { allocBuffer, allocBufferUnsafe, bufferCompare, bufferConcat, bufferEquals, bufferFrom, bufferSliceCopy, isNaN, readUInt64LE, writeUInt64LE, } from './compat.js';
13
13
  export { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.js';
14
+ export { default as EntryStream } from './EntryStream.js';
@@ -11,3 +11,4 @@
11
11
  */
12
12
  export { allocBuffer, allocBufferUnsafe, bufferCompare, bufferConcat, bufferEquals, bufferFrom, bufferSliceCopy, isNaN, readUInt64LE, writeUInt64LE, } from './compat.js';
13
13
  export { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.js';
14
+ export { default as EntryStream } from './EntryStream.js';
@@ -19,6 +19,9 @@ function _export(target, all) {
19
19
  });
20
20
  }
21
21
  _export(exports, {
22
+ get EntryStream () {
23
+ return _EntryStreamts.default;
24
+ },
22
25
  get allocBuffer () {
23
26
  return _compatts.allocBuffer;
24
27
  },
@@ -64,4 +67,10 @@ _export(exports, {
64
67
  });
65
68
  var _compatts = require("./compat.js");
66
69
  var _crc32ts = require("./crc32.js");
70
+ var _EntryStreamts = /*#__PURE__*/ _interop_require_default(require("./EntryStream.js"));
71
+ function _interop_require_default(obj) {
72
+ return obj && obj.__esModule ? obj : {
73
+ default: obj
74
+ };
75
+ }
67
76
  /* 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/index.ts"],"sourcesContent":["/**\n * Shared utilities for iterator libraries\n *\n * These utilities are designed to be used by:\n * - zip-iterator\n * - 7z-iterator\n * - tar-iterator\n * - Any other archive iterator library\n *\n * All utilities support Node.js 0.8+\n */\n\nexport {\n allocBuffer,\n allocBufferUnsafe,\n bufferCompare,\n bufferConcat,\n bufferEquals,\n bufferFrom,\n bufferSliceCopy,\n isNaN,\n readUInt64LE,\n writeUInt64LE,\n} from './compat.ts';\n\nexport { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.ts';\n"],"names":["allocBuffer","allocBufferUnsafe","bufferCompare","bufferConcat","bufferEquals","bufferFrom","bufferSliceCopy","crc32","crc32Region","isNaN","readUInt64LE","verifyCrc32","verifyCrc32Region","writeUInt64LE"],"mappings":"AAAA;;;;;;;;;;CAUC;;;;;;;;;;;QAGCA;eAAAA,qBAAW;;QACXC;eAAAA,2BAAiB;;QACjBC;eAAAA,uBAAa;;QACbC;eAAAA,sBAAY;;QACZC;eAAAA,sBAAY;;QACZC;eAAAA,oBAAU;;QACVC;eAAAA,yBAAe;;QAMRC;eAAAA,cAAK;;QAAEC;eAAAA,oBAAW;;QALzBC;eAAAA,eAAK;;QACLC;eAAAA,sBAAY;;QAIeC;eAAAA,oBAAW;;QAAEC;eAAAA,0BAAiB;;QAHzDC;eAAAA,uBAAa;;;wBACR;uBAE4D"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/index.ts"],"sourcesContent":["/**\n * Shared utilities for iterator libraries\n *\n * These utilities are designed to be used by:\n * - zip-iterator\n * - 7z-iterator\n * - tar-iterator\n * - Any other archive iterator library\n *\n * All utilities support Node.js 0.8+\n */\n\nexport {\n allocBuffer,\n allocBufferUnsafe,\n bufferCompare,\n bufferConcat,\n bufferEquals,\n bufferFrom,\n bufferSliceCopy,\n isNaN,\n readUInt64LE,\n writeUInt64LE,\n} from './compat.ts';\n\nexport { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.ts';\n\nexport { default as EntryStream } from './EntryStream.ts';\n"],"names":["EntryStream","allocBuffer","allocBufferUnsafe","bufferCompare","bufferConcat","bufferEquals","bufferFrom","bufferSliceCopy","crc32","crc32Region","isNaN","readUInt64LE","verifyCrc32","verifyCrc32Region","writeUInt64LE"],"mappings":"AAAA;;;;;;;;;;CAUC;;;;;;;;;;;QAiBmBA;eAAAA,sBAAW;;QAd7BC;eAAAA,qBAAW;;QACXC;eAAAA,2BAAiB;;QACjBC;eAAAA,uBAAa;;QACbC;eAAAA,sBAAY;;QACZC;eAAAA,sBAAY;;QACZC;eAAAA,oBAAU;;QACVC;eAAAA,yBAAe;;QAMRC;eAAAA,cAAK;;QAAEC;eAAAA,oBAAW;;QALzBC;eAAAA,eAAK;;QACLC;eAAAA,sBAAY;;QAIeC;eAAAA,oBAAW;;QAAEC;eAAAA,0BAAiB;;QAHzDC;eAAAA,uBAAa;;;wBACR;uBAE4D;oEAE5B"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * EntryStream - Simple readable-like stream for entry content
3
+ *
4
+ * Extends EventEmitter to emit 'data', 'end', 'error' events.
5
+ * Node 0.8 compatible.
6
+ *
7
+ * This base class is designed to be used by:
8
+ * - zip-iterator
9
+ * - 7z-iterator
10
+ * - tar-iterator
11
+ * - Any other archive iterator library
12
+ */
13
+ import { EventEmitter } from 'events';
14
+ /**
15
+ * Base stream class for archive entry content.
16
+ * Can be extended for special entry types like sparse files.
17
+ */
18
+ export default class EntryStream extends EventEmitter {
19
+ protected _paused: boolean;
20
+ protected _ended: boolean;
21
+ protected _endEmitted: boolean;
22
+ protected _buffered: Buffer[];
23
+ /**
24
+ * Push data to the stream
25
+ */
26
+ push(data: Buffer): void;
27
+ /**
28
+ * End the stream
29
+ */
30
+ end(): void;
31
+ /**
32
+ * Resume reading (drain buffered data)
33
+ */
34
+ resume(): this;
35
+ /**
36
+ * Pause reading
37
+ */
38
+ pause(): this;
39
+ /**
40
+ * Check if stream has ended
41
+ */
42
+ get ended(): boolean;
43
+ /**
44
+ * Pipe to a writable stream
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)
53
+ */
54
+ protected _emitEnd(): void;
55
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * EntryStream - Simple readable-like stream for entry content
3
+ *
4
+ * Extends EventEmitter to emit 'data', 'end', 'error' events.
5
+ * Node 0.8 compatible.
6
+ *
7
+ * This base class is designed to be used by:
8
+ * - zip-iterator
9
+ * - 7z-iterator
10
+ * - tar-iterator
11
+ * - Any other archive iterator library
12
+ */ import { EventEmitter } from 'events';
13
+ let EntryStream = class EntryStream extends EventEmitter {
14
+ /**
15
+ * Push data to the stream
16
+ */ push(data) {
17
+ if (this._ended) return;
18
+ if (this._paused) {
19
+ this._buffered.push(data);
20
+ } else {
21
+ this.emit('data', data);
22
+ }
23
+ }
24
+ /**
25
+ * End the stream
26
+ */ end() {
27
+ if (this._ended) return;
28
+ this._ended = true;
29
+ // If not paused, flush and emit end now
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;
53
+ }
54
+ /**
55
+ * Check if stream has ended
56
+ */ get ended() {
57
+ return this._ended;
58
+ }
59
+ /**
60
+ * Pipe to a writable stream
61
+ */ pipe(dest) {
62
+ var self = this;
63
+ // Cast to EventEmitter-compatible type for backpressure handling
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');
97
+ }
98
+ constructor(...args){
99
+ super(...args), this._paused = true, this._ended = false, this._endEmitted = false, this._buffered = [];
100
+ }
101
+ };
102
+ /**
103
+ * Base stream class for archive entry content.
104
+ * Can be extended for special entry types like sparse files.
105
+ */ export { EntryStream as default };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/EntryStream.ts"],"sourcesContent":["/**\n * EntryStream - Simple readable-like stream for entry content\n *\n * Extends EventEmitter to emit 'data', 'end', 'error' events.\n * Node 0.8 compatible.\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 { EventEmitter } from 'events';\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 EventEmitter {\n protected _paused = true;\n protected _ended = false;\n protected _endEmitted = false;\n protected _buffered: Buffer[] = [];\n\n /**\n * Push data to the stream\n */\n push(data: Buffer): void {\n if (this._ended) return;\n\n if (this._paused) {\n this._buffered.push(data);\n } else {\n this.emit('data', data);\n }\n }\n\n /**\n * End the stream\n */\n end(): void {\n if (this._ended) return;\n this._ended = true;\n\n // If not paused, flush and emit end now\n if (!this._paused) {\n this._flush();\n this._emitEnd();\n }\n // Otherwise, end will be emitted when resume() is called\n }\n\n /**\n * Resume reading (drain buffered data)\n */\n resume(): this {\n if (!this._paused) return this;\n this._paused = false;\n this._flush();\n // If stream was ended while paused, emit end now\n if (this._ended && !this._endEmitted) {\n this._emitEnd();\n }\n return this;\n }\n\n /**\n * Pause reading\n */\n pause(): this {\n this._paused = true;\n return this;\n }\n\n /**\n * Check if stream has ended\n */\n get ended(): boolean {\n return this._ended;\n }\n\n /**\n * Pipe to a writable stream\n */\n pipe<T extends NodeJS.WritableStream>(dest: T): T {\n var self = this;\n // Cast to EventEmitter-compatible type for backpressure handling\n var emitter = dest as T & { once?: (event: string, fn: () => void) => void };\n this.on('data', function onData(chunk: Buffer) {\n var canContinue = dest.write(chunk);\n // Handle backpressure if dest returns false\n if (canContinue === false && typeof emitter.once === 'function') {\n self.pause();\n emitter.once('drain', function onDrain() {\n self.resume();\n });\n }\n });\n\n this.on('end', function onEnd() {\n if (typeof dest.end === 'function') {\n dest.end();\n }\n });\n\n this.resume();\n return dest;\n }\n\n /**\n * Flush buffered data\n */\n protected _flush(): void {\n while (this._buffered.length > 0) {\n var chunk = this._buffered.shift();\n this.emit('data', chunk);\n }\n }\n\n /**\n * Emit end event (only once)\n */\n protected _emitEnd(): void {\n if (this._endEmitted) return;\n this._endEmitted = true;\n this.emit('end');\n }\n}\n"],"names":["EventEmitter","EntryStream","push","data","_ended","_paused","_buffered","emit","end","_flush","_emitEnd","resume","_endEmitted","pause","ended","pipe","dest","self","emitter","on","onData","chunk","canContinue","write","once","onDrain","onEnd","length","shift"],"mappings":"AAAA;;;;;;;;;;;CAWC,GAED,SAASA,YAAY,QAAQ,SAAS;AAMvB,IAAA,AAAMC,cAAN,MAAMA,oBAAoBD;IAMvC;;GAEC,GACDE,KAAKC,IAAY,EAAQ;QACvB,IAAI,IAAI,CAACC,MAAM,EAAE;QAEjB,IAAI,IAAI,CAACC,OAAO,EAAE;YAChB,IAAI,CAACC,SAAS,CAACJ,IAAI,CAACC;QACtB,OAAO;YACL,IAAI,CAACI,IAAI,CAAC,QAAQJ;QACpB;IACF;IAEA;;GAEC,GACDK,MAAY;QACV,IAAI,IAAI,CAACJ,MAAM,EAAE;QACjB,IAAI,CAACA,MAAM,GAAG;QAEd,wCAAwC;QACxC,IAAI,CAAC,IAAI,CAACC,OAAO,EAAE;YACjB,IAAI,CAACI,MAAM;YACX,IAAI,CAACC,QAAQ;QACf;IACA,yDAAyD;IAC3D;IAEA;;GAEC,GACDC,SAAe;QACb,IAAI,CAAC,IAAI,CAACN,OAAO,EAAE,OAAO,IAAI;QAC9B,IAAI,CAACA,OAAO,GAAG;QACf,IAAI,CAACI,MAAM;QACX,iDAAiD;QACjD,IAAI,IAAI,CAACL,MAAM,IAAI,CAAC,IAAI,CAACQ,WAAW,EAAE;YACpC,IAAI,CAACF,QAAQ;QACf;QACA,OAAO,IAAI;IACb;IAEA;;GAEC,GACDG,QAAc;QACZ,IAAI,CAACR,OAAO,GAAG;QACf,OAAO,IAAI;IACb;IAEA;;GAEC,GACD,IAAIS,QAAiB;QACnB,OAAO,IAAI,CAACV,MAAM;IACpB;IAEA;;GAEC,GACDW,KAAsCC,IAAO,EAAK;QAChD,IAAIC,OAAO,IAAI;QACf,iEAAiE;QACjE,IAAIC,UAAUF;QACd,IAAI,CAACG,EAAE,CAAC,QAAQ,SAASC,OAAOC,KAAa;YAC3C,IAAIC,cAAcN,KAAKO,KAAK,CAACF;YAC7B,4CAA4C;YAC5C,IAAIC,gBAAgB,SAAS,OAAOJ,QAAQM,IAAI,KAAK,YAAY;gBAC/DP,KAAKJ,KAAK;gBACVK,QAAQM,IAAI,CAAC,SAAS,SAASC;oBAC7BR,KAAKN,MAAM;gBACb;YACF;QACF;QAEA,IAAI,CAACQ,EAAE,CAAC,OAAO,SAASO;YACtB,IAAI,OAAOV,KAAKR,GAAG,KAAK,YAAY;gBAClCQ,KAAKR,GAAG;YACV;QACF;QAEA,IAAI,CAACG,MAAM;QACX,OAAOK;IACT;IAEA;;GAEC,GACD,AAAUP,SAAe;QACvB,MAAO,IAAI,CAACH,SAAS,CAACqB,MAAM,GAAG,EAAG;YAChC,IAAIN,QAAQ,IAAI,CAACf,SAAS,CAACsB,KAAK;YAChC,IAAI,CAACrB,IAAI,CAAC,QAAQc;QACpB;IACF;IAEA;;GAEC,GACD,AAAUX,WAAiB;QACzB,IAAI,IAAI,CAACE,WAAW,EAAE;QACtB,IAAI,CAACA,WAAW,GAAG;QACnB,IAAI,CAACL,IAAI,CAAC;IACZ;;QA5Ga,qBACHF,UAAU,WACVD,SAAS,YACTQ,cAAc,YACdN,YAAsB,EAAE;;AAyGpC;AAjHA;;;CAGC,GACD,SAAqBL,yBA6GpB"}
@@ -11,3 +11,4 @@
11
11
  */
12
12
  export { allocBuffer, allocBufferUnsafe, bufferCompare, bufferConcat, bufferEquals, bufferFrom, bufferSliceCopy, isNaN, readUInt64LE, writeUInt64LE, } from './compat.js';
13
13
  export { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.js';
14
+ export { default as EntryStream } from './EntryStream.js';
@@ -10,3 +10,4 @@
10
10
  * All utilities support Node.js 0.8+
11
11
  */ export { allocBuffer, allocBufferUnsafe, bufferCompare, bufferConcat, bufferEquals, bufferFrom, bufferSliceCopy, isNaN, readUInt64LE, writeUInt64LE } from './compat.js';
12
12
  export { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.js';
13
+ export { default as EntryStream } from './EntryStream.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/index.ts"],"sourcesContent":["/**\n * Shared utilities for iterator libraries\n *\n * These utilities are designed to be used by:\n * - zip-iterator\n * - 7z-iterator\n * - tar-iterator\n * - Any other archive iterator library\n *\n * All utilities support Node.js 0.8+\n */\n\nexport {\n allocBuffer,\n allocBufferUnsafe,\n bufferCompare,\n bufferConcat,\n bufferEquals,\n bufferFrom,\n bufferSliceCopy,\n isNaN,\n readUInt64LE,\n writeUInt64LE,\n} from './compat.ts';\n\nexport { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.ts';\n"],"names":["allocBuffer","allocBufferUnsafe","bufferCompare","bufferConcat","bufferEquals","bufferFrom","bufferSliceCopy","isNaN","readUInt64LE","writeUInt64LE","crc32","crc32Region","verifyCrc32","verifyCrc32Region"],"mappings":"AAAA;;;;;;;;;;CAUC,GAED,SACEA,WAAW,EACXC,iBAAiB,EACjBC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,eAAe,EACfC,KAAK,EACLC,YAAY,EACZC,aAAa,QACR,cAAc;AAErB,SAASC,KAAK,EAAEC,WAAW,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ,aAAa"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/index.ts"],"sourcesContent":["/**\n * Shared utilities for iterator libraries\n *\n * These utilities are designed to be used by:\n * - zip-iterator\n * - 7z-iterator\n * - tar-iterator\n * - Any other archive iterator library\n *\n * All utilities support Node.js 0.8+\n */\n\nexport {\n allocBuffer,\n allocBufferUnsafe,\n bufferCompare,\n bufferConcat,\n bufferEquals,\n bufferFrom,\n bufferSliceCopy,\n isNaN,\n readUInt64LE,\n writeUInt64LE,\n} from './compat.ts';\n\nexport { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.ts';\n\nexport { default as EntryStream } from './EntryStream.ts';\n"],"names":["allocBuffer","allocBufferUnsafe","bufferCompare","bufferConcat","bufferEquals","bufferFrom","bufferSliceCopy","isNaN","readUInt64LE","writeUInt64LE","crc32","crc32Region","verifyCrc32","verifyCrc32Region","default","EntryStream"],"mappings":"AAAA;;;;;;;;;;CAUC,GAED,SACEA,WAAW,EACXC,iBAAiB,EACjBC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,UAAU,EACVC,eAAe,EACfC,KAAK,EACLC,YAAY,EACZC,aAAa,QACR,cAAc;AAErB,SAASC,KAAK,EAAEC,WAAW,EAAEC,WAAW,EAAEC,iBAAiB,QAAQ,aAAa;AAEhF,SAASC,WAAWC,WAAW,QAAQ,mBAAmB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extract-base-iterator",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Base iterator for extract iterators like tar-iterator and zip-iterator",
5
5
  "keywords": [
6
6
  "extract",