extract-base-iterator 2.2.6 → 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.
Files changed (36) hide show
  1. package/dist/cjs/index.d.cts +1 -0
  2. package/dist/cjs/index.d.ts +1 -0
  3. package/dist/cjs/index.js +1 -0
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/shared/EntryStream.d.cts +55 -0
  6. package/dist/cjs/shared/EntryStream.d.ts +55 -0
  7. package/dist/cjs/shared/EntryStream.js +197 -0
  8. package/dist/cjs/shared/EntryStream.js.map +1 -0
  9. package/dist/cjs/shared/compat.d.cts +78 -0
  10. package/dist/cjs/shared/compat.d.ts +78 -0
  11. package/dist/cjs/shared/compat.js +177 -0
  12. package/dist/cjs/shared/compat.js.map +1 -0
  13. package/dist/cjs/shared/crc32.d.cts +45 -0
  14. package/dist/cjs/shared/crc32.d.ts +45 -0
  15. package/dist/cjs/shared/crc32.js +76 -0
  16. package/dist/cjs/shared/crc32.js.map +1 -0
  17. package/dist/cjs/shared/index.d.cts +14 -0
  18. package/dist/cjs/shared/index.d.ts +14 -0
  19. package/dist/cjs/shared/index.js +76 -0
  20. package/dist/cjs/shared/index.js.map +1 -0
  21. package/dist/esm/index.d.ts +1 -0
  22. package/dist/esm/index.js +2 -0
  23. package/dist/esm/index.js.map +1 -1
  24. package/dist/esm/shared/EntryStream.d.ts +55 -0
  25. package/dist/esm/shared/EntryStream.js +105 -0
  26. package/dist/esm/shared/EntryStream.js.map +1 -0
  27. package/dist/esm/shared/compat.d.ts +78 -0
  28. package/dist/esm/shared/compat.js +173 -0
  29. package/dist/esm/shared/compat.js.map +1 -0
  30. package/dist/esm/shared/crc32.d.ts +45 -0
  31. package/dist/esm/shared/crc32.js +75 -0
  32. package/dist/esm/shared/crc32.js.map +1 -0
  33. package/dist/esm/shared/index.d.ts +14 -0
  34. package/dist/esm/shared/index.js +13 -0
  35. package/dist/esm/shared/index.js.map +1 -0
  36. package/package.json +2 -1
@@ -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;QAC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Qc;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"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Buffer Compatibility Layer for Node.js 0.8+
3
+ *
4
+ * Provides buffer utilities that work across all Node.js versions
5
+ * WITHOUT modifying global Buffer object.
6
+ *
7
+ * Version history:
8
+ * - Node 0.8-4.4: Only has `new Buffer()`, no `Buffer.alloc/from`
9
+ * - Node 4.5+: Has `Buffer.alloc/from`, deprecates `new Buffer()`
10
+ * - Node 10+: Warns or errors on `new Buffer()`
11
+ *
12
+ * Solution: Feature detection with graceful fallback in both directions.
13
+ */
14
+ /**
15
+ * Allocate a zero-filled buffer (safe)
16
+ * - Uses Buffer.alloc() on Node 4.5+
17
+ * - Falls back to new Buffer() + fill on Node 0.8-4.4
18
+ */
19
+ export declare function allocBuffer(size: number): Buffer;
20
+ /**
21
+ * Allocate a buffer without initialization (unsafe but faster)
22
+ * - Uses Buffer.allocUnsafe() on Node 4.5+
23
+ * - Falls back to new Buffer() on Node 0.8-4.4
24
+ *
25
+ * WARNING: Buffer contents are uninitialized and may contain sensitive data.
26
+ * Only use when you will immediately overwrite all bytes.
27
+ */
28
+ export declare function allocBufferUnsafe(size: number): Buffer;
29
+ /**
30
+ * Create a buffer from string, array, or existing buffer
31
+ * - Uses Buffer.from() on Node 4.5+
32
+ * - Falls back to new Buffer() on Node 0.8-4.4
33
+ * - Handles Uint8Array conversion for Node 0.8 (crypto output compatibility)
34
+ */
35
+ export declare function bufferFrom(data: string | number[] | Buffer | Uint8Array, encoding?: BufferEncoding): Buffer;
36
+ /**
37
+ * Compare two buffers or buffer regions
38
+ * - Uses Buffer.compare() on Node 5.10+ (with offset support)
39
+ * - Falls back to manual comparison on Node 0.8-5.9
40
+ */
41
+ export declare function bufferCompare(source: Buffer, target: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
42
+ /**
43
+ * Check if buffer region equals byte array
44
+ * Useful for magic number detection without Buffer.from()
45
+ */
46
+ export declare function bufferEquals(buf: Buffer, offset: number, expected: number[]): boolean;
47
+ /**
48
+ * Copy buffer region to new buffer
49
+ * Works on all Node versions
50
+ */
51
+ export declare function bufferSliceCopy(buf: Buffer, start: number, end: number): Buffer;
52
+ /**
53
+ * Read 64-bit unsigned integer (little-endian)
54
+ * Uses two 32-bit reads since BigInt not available until Node 10.4
55
+ *
56
+ * WARNING: Only accurate for values < Number.MAX_SAFE_INTEGER (2^53 - 1)
57
+ * This covers files up to ~9 PB which is practical for all real use cases.
58
+ */
59
+ export declare function readUInt64LE(buf: Buffer, offset: number): number;
60
+ /**
61
+ * Write 64-bit unsigned integer (little-endian)
62
+ * Same precision limitation as readUInt64LE
63
+ */
64
+ export declare function writeUInt64LE(buf: Buffer, value: number, offset: number): void;
65
+ /**
66
+ * Concatenate buffers - compatible with Node 0.8
67
+ * Handles crypto output which may not be proper Buffer instances in old Node.
68
+ *
69
+ * NOTE: This function is primarily needed for AES decryption compatibility
70
+ * in Node 0.8 where crypto output may not be proper Buffer instances.
71
+ * Libraries not using crypto can use native Buffer.concat() directly.
72
+ */
73
+ export declare function bufferConcat(list: (Buffer | Uint8Array)[], totalLength?: number): Buffer;
74
+ /**
75
+ * Node 0.8 compatible isNaN (Number.isNaN didn't exist until ES2015)
76
+ * Uses self-comparison: NaN is the only value not equal to itself
77
+ */
78
+ export declare function isNaN(value: number): boolean;
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Buffer Compatibility Layer for Node.js 0.8+
3
+ *
4
+ * Provides buffer utilities that work across all Node.js versions
5
+ * WITHOUT modifying global Buffer object.
6
+ *
7
+ * Version history:
8
+ * - Node 0.8-4.4: Only has `new Buffer()`, no `Buffer.alloc/from`
9
+ * - Node 4.5+: Has `Buffer.alloc/from`, deprecates `new Buffer()`
10
+ * - Node 10+: Warns or errors on `new Buffer()`
11
+ *
12
+ * Solution: Feature detection with graceful fallback in both directions.
13
+ */ // Feature detection (runs once at module load)
14
+ var hasBufferAlloc = typeof Buffer.alloc === 'function';
15
+ var hasBufferAllocUnsafe = typeof Buffer.allocUnsafe === 'function';
16
+ var hasBufferFrom = typeof Buffer.from === 'function' && Buffer.from !== Uint8Array.from;
17
+ /**
18
+ * Allocate a zero-filled buffer (safe)
19
+ * - Uses Buffer.alloc() on Node 4.5+
20
+ * - Falls back to new Buffer() + fill on Node 0.8-4.4
21
+ */ export function allocBuffer(size) {
22
+ if (hasBufferAlloc) {
23
+ return Buffer.alloc(size);
24
+ }
25
+ // Legacy fallback: new Buffer() is uninitialized, must zero-fill
26
+ var buf = new Buffer(size);
27
+ buf.fill(0);
28
+ return buf;
29
+ }
30
+ /**
31
+ * Allocate a buffer without initialization (unsafe but faster)
32
+ * - Uses Buffer.allocUnsafe() on Node 4.5+
33
+ * - Falls back to new Buffer() on Node 0.8-4.4
34
+ *
35
+ * WARNING: Buffer contents are uninitialized and may contain sensitive data.
36
+ * Only use when you will immediately overwrite all bytes.
37
+ */ export function allocBufferUnsafe(size) {
38
+ if (hasBufferAllocUnsafe) {
39
+ return Buffer.allocUnsafe(size);
40
+ }
41
+ return new Buffer(size);
42
+ }
43
+ /**
44
+ * Create a buffer from string, array, or existing buffer
45
+ * - Uses Buffer.from() on Node 4.5+
46
+ * - Falls back to new Buffer() on Node 0.8-4.4
47
+ * - Handles Uint8Array conversion for Node 0.8 (crypto output compatibility)
48
+ */ export function bufferFrom(data, encoding) {
49
+ if (hasBufferFrom) {
50
+ if (typeof data === 'string') {
51
+ return Buffer.from(data, encoding);
52
+ }
53
+ return Buffer.from(data);
54
+ }
55
+ // Node 0.8 compatibility - deprecated Buffer constructor
56
+ // For Uint8Array, convert to array first (needed for crypto output in Node 0.8)
57
+ if (data instanceof Uint8Array && !(data instanceof Buffer)) {
58
+ var arr = [];
59
+ for(var i = 0; i < data.length; i++){
60
+ arr.push(data[i]);
61
+ }
62
+ return new Buffer(arr);
63
+ }
64
+ return new Buffer(data, encoding);
65
+ }
66
+ /**
67
+ * Compare two buffers or buffer regions
68
+ * - Uses Buffer.compare() on Node 5.10+ (with offset support)
69
+ * - Falls back to manual comparison on Node 0.8-5.9
70
+ */ export function bufferCompare(source, target, targetStart, targetEnd, sourceStart, sourceEnd) {
71
+ sourceStart = sourceStart || 0;
72
+ sourceEnd = sourceEnd || source.length;
73
+ targetStart = targetStart || 0;
74
+ targetEnd = targetEnd || target.length;
75
+ // Check if native compare with offset support exists (Node 5.10+)
76
+ if (source.compare && source.compare.length >= 5) {
77
+ return source.compare(target, targetStart, targetEnd, sourceStart, sourceEnd);
78
+ }
79
+ // Manual comparison for older Node versions
80
+ var sourceLen = sourceEnd - sourceStart;
81
+ var targetLen = targetEnd - targetStart;
82
+ var len = Math.min(sourceLen, targetLen);
83
+ for(var i = 0; i < len; i++){
84
+ var s = source[sourceStart + i];
85
+ var t = target[targetStart + i];
86
+ if (s !== t) return s < t ? -1 : 1;
87
+ }
88
+ return sourceLen - targetLen;
89
+ }
90
+ /**
91
+ * Check if buffer region equals byte array
92
+ * Useful for magic number detection without Buffer.from()
93
+ */ export function bufferEquals(buf, offset, expected) {
94
+ if (offset + expected.length > buf.length) return false;
95
+ for(var i = 0; i < expected.length; i++){
96
+ if (buf[offset + i] !== expected[i]) return false;
97
+ }
98
+ return true;
99
+ }
100
+ /**
101
+ * Copy buffer region to new buffer
102
+ * Works on all Node versions
103
+ */ export function bufferSliceCopy(buf, start, end) {
104
+ var result = allocBuffer(end - start);
105
+ buf.copy(result, 0, start, end);
106
+ return result;
107
+ }
108
+ /**
109
+ * Read 64-bit unsigned integer (little-endian)
110
+ * Uses two 32-bit reads since BigInt not available until Node 10.4
111
+ *
112
+ * WARNING: Only accurate for values < Number.MAX_SAFE_INTEGER (2^53 - 1)
113
+ * This covers files up to ~9 PB which is practical for all real use cases.
114
+ */ export function readUInt64LE(buf, offset) {
115
+ var low = buf.readUInt32LE(offset);
116
+ var high = buf.readUInt32LE(offset + 4);
117
+ return high * 0x100000000 + low;
118
+ }
119
+ /**
120
+ * Write 64-bit unsigned integer (little-endian)
121
+ * Same precision limitation as readUInt64LE
122
+ */ export function writeUInt64LE(buf, value, offset) {
123
+ var low = value >>> 0;
124
+ var high = value / 0x100000000 >>> 0;
125
+ buf.writeUInt32LE(low, offset);
126
+ buf.writeUInt32LE(high, offset + 4);
127
+ }
128
+ /**
129
+ * Concatenate buffers - compatible with Node 0.8
130
+ * Handles crypto output which may not be proper Buffer instances in old Node.
131
+ *
132
+ * NOTE: This function is primarily needed for AES decryption compatibility
133
+ * in Node 0.8 where crypto output may not be proper Buffer instances.
134
+ * Libraries not using crypto can use native Buffer.concat() directly.
135
+ */ export function bufferConcat(list, totalLength) {
136
+ // Calculate actual total length first
137
+ var actualLength = 0;
138
+ for(var i = 0; i < list.length; i++){
139
+ actualLength += list[i].length;
140
+ }
141
+ // Use specified totalLength or actual length
142
+ var targetLength = totalLength !== undefined ? totalLength : actualLength;
143
+ // Check if all items are proper Buffers AND no truncation needed
144
+ // (Node 0.8's Buffer.concat doesn't handle truncation well)
145
+ var allBuffers = true;
146
+ for(var j = 0; j < list.length; j++){
147
+ if (!(list[j] instanceof Buffer)) {
148
+ allBuffers = false;
149
+ break;
150
+ }
151
+ }
152
+ if (allBuffers && targetLength >= actualLength) {
153
+ return Buffer.concat(list, targetLength);
154
+ }
155
+ // Manual concat for mixed types or when truncation is needed
156
+ var result = allocBuffer(targetLength);
157
+ var offset = 0;
158
+ for(var k = 0; k < list.length && offset < targetLength; k++){
159
+ var buf = list[k];
160
+ for(var l = 0; l < buf.length && offset < targetLength; l++){
161
+ result[offset++] = buf[l];
162
+ }
163
+ }
164
+ return result;
165
+ }
166
+ /**
167
+ * Node 0.8 compatible isNaN (Number.isNaN didn't exist until ES2015)
168
+ * Uses self-comparison: NaN is the only value not equal to itself
169
+ */ // biome-ignore lint/suspicious/noShadowRestrictedNames: Legacy compatibility
170
+ export function isNaN(value) {
171
+ // biome-ignore lint/suspicious/noSelfCompare: NaN check pattern
172
+ return value !== value;
173
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/compat.ts"],"sourcesContent":["/**\n * Buffer Compatibility Layer for Node.js 0.8+\n *\n * Provides buffer utilities that work across all Node.js versions\n * WITHOUT modifying global Buffer object.\n *\n * Version history:\n * - Node 0.8-4.4: Only has `new Buffer()`, no `Buffer.alloc/from`\n * - Node 4.5+: Has `Buffer.alloc/from`, deprecates `new Buffer()`\n * - Node 10+: Warns or errors on `new Buffer()`\n *\n * Solution: Feature detection with graceful fallback in both directions.\n */\n\n// Feature detection (runs once at module load)\nvar hasBufferAlloc = typeof Buffer.alloc === 'function';\nvar hasBufferAllocUnsafe = typeof Buffer.allocUnsafe === 'function';\nvar hasBufferFrom = typeof Buffer.from === 'function' && Buffer.from !== Uint8Array.from;\n\n/**\n * Allocate a zero-filled buffer (safe)\n * - Uses Buffer.alloc() on Node 4.5+\n * - Falls back to new Buffer() + fill on Node 0.8-4.4\n */\nexport function allocBuffer(size: number): Buffer {\n if (hasBufferAlloc) {\n return Buffer.alloc(size);\n }\n // Legacy fallback: new Buffer() is uninitialized, must zero-fill\n var buf = new Buffer(size);\n buf.fill(0);\n return buf;\n}\n\n/**\n * Allocate a buffer without initialization (unsafe but faster)\n * - Uses Buffer.allocUnsafe() on Node 4.5+\n * - Falls back to new Buffer() on Node 0.8-4.4\n *\n * WARNING: Buffer contents are uninitialized and may contain sensitive data.\n * Only use when you will immediately overwrite all bytes.\n */\nexport function allocBufferUnsafe(size: number): Buffer {\n if (hasBufferAllocUnsafe) {\n return Buffer.allocUnsafe(size);\n }\n return new Buffer(size);\n}\n\n/**\n * Create a buffer from string, array, or existing buffer\n * - Uses Buffer.from() on Node 4.5+\n * - Falls back to new Buffer() on Node 0.8-4.4\n * - Handles Uint8Array conversion for Node 0.8 (crypto output compatibility)\n */\nexport function bufferFrom(data: string | number[] | Buffer | Uint8Array, encoding?: BufferEncoding): Buffer {\n if (hasBufferFrom) {\n if (typeof data === 'string') {\n return Buffer.from(data, encoding);\n }\n return Buffer.from(data as number[] | Buffer);\n }\n // Node 0.8 compatibility - deprecated Buffer constructor\n // For Uint8Array, convert to array first (needed for crypto output in Node 0.8)\n if (data instanceof Uint8Array && !(data instanceof Buffer)) {\n var arr: number[] = [];\n for (var i = 0; i < data.length; i++) {\n arr.push(data[i]);\n }\n return new Buffer(arr);\n }\n return new Buffer(data as string & number[], encoding);\n}\n\n/**\n * Compare two buffers or buffer regions\n * - Uses Buffer.compare() on Node 5.10+ (with offset support)\n * - Falls back to manual comparison on Node 0.8-5.9\n */\nexport function bufferCompare(source: Buffer, target: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number {\n sourceStart = sourceStart || 0;\n sourceEnd = sourceEnd || source.length;\n targetStart = targetStart || 0;\n targetEnd = targetEnd || target.length;\n\n // Check if native compare with offset support exists (Node 5.10+)\n if (source.compare && source.compare.length >= 5) {\n return source.compare(target, targetStart, targetEnd, sourceStart, sourceEnd);\n }\n\n // Manual comparison for older Node versions\n var sourceLen = sourceEnd - sourceStart;\n var targetLen = targetEnd - targetStart;\n var len = Math.min(sourceLen, targetLen);\n\n for (var i = 0; i < len; i++) {\n var s = source[sourceStart + i];\n var t = target[targetStart + i];\n if (s !== t) return s < t ? -1 : 1;\n }\n\n return sourceLen - targetLen;\n}\n\n/**\n * Check if buffer region equals byte array\n * Useful for magic number detection without Buffer.from()\n */\nexport function bufferEquals(buf: Buffer, offset: number, expected: number[]): boolean {\n if (offset + expected.length > buf.length) return false;\n for (var i = 0; i < expected.length; i++) {\n if (buf[offset + i] !== expected[i]) return false;\n }\n return true;\n}\n\n/**\n * Copy buffer region to new buffer\n * Works on all Node versions\n */\nexport function bufferSliceCopy(buf: Buffer, start: number, end: number): Buffer {\n var result = allocBuffer(end - start);\n buf.copy(result, 0, start, end);\n return result;\n}\n\n/**\n * Read 64-bit unsigned integer (little-endian)\n * Uses two 32-bit reads since BigInt not available until Node 10.4\n *\n * WARNING: Only accurate for values < Number.MAX_SAFE_INTEGER (2^53 - 1)\n * This covers files up to ~9 PB which is practical for all real use cases.\n */\nexport function readUInt64LE(buf: Buffer, offset: number): number {\n var low = buf.readUInt32LE(offset);\n var high = buf.readUInt32LE(offset + 4);\n return high * 0x100000000 + low;\n}\n\n/**\n * Write 64-bit unsigned integer (little-endian)\n * Same precision limitation as readUInt64LE\n */\nexport function writeUInt64LE(buf: Buffer, value: number, offset: number): void {\n var low = value >>> 0;\n var high = (value / 0x100000000) >>> 0;\n buf.writeUInt32LE(low, offset);\n buf.writeUInt32LE(high, offset + 4);\n}\n\n/**\n * Concatenate buffers - compatible with Node 0.8\n * Handles crypto output which may not be proper Buffer instances in old Node.\n *\n * NOTE: This function is primarily needed for AES decryption compatibility\n * in Node 0.8 where crypto output may not be proper Buffer instances.\n * Libraries not using crypto can use native Buffer.concat() directly.\n */\nexport function bufferConcat(list: (Buffer | Uint8Array)[], totalLength?: number): Buffer {\n // Calculate actual total length first\n var actualLength = 0;\n for (var i = 0; i < list.length; i++) {\n actualLength += list[i].length;\n }\n\n // Use specified totalLength or actual length\n var targetLength = totalLength !== undefined ? totalLength : actualLength;\n\n // Check if all items are proper Buffers AND no truncation needed\n // (Node 0.8's Buffer.concat doesn't handle truncation well)\n var allBuffers = true;\n for (var j = 0; j < list.length; j++) {\n if (!(list[j] instanceof Buffer)) {\n allBuffers = false;\n break;\n }\n }\n if (allBuffers && targetLength >= actualLength) {\n return Buffer.concat(list as Buffer[], targetLength);\n }\n\n // Manual concat for mixed types or when truncation is needed\n var result = allocBuffer(targetLength);\n var offset = 0;\n for (var k = 0; k < list.length && offset < targetLength; k++) {\n var buf = list[k];\n for (var l = 0; l < buf.length && offset < targetLength; l++) {\n result[offset++] = buf[l];\n }\n }\n return result;\n}\n\n/**\n * Node 0.8 compatible isNaN (Number.isNaN didn't exist until ES2015)\n * Uses self-comparison: NaN is the only value not equal to itself\n */\n// biome-ignore lint/suspicious/noShadowRestrictedNames: Legacy compatibility\nexport function isNaN(value: number): boolean {\n // biome-ignore lint/suspicious/noSelfCompare: NaN check pattern\n return value !== value;\n}\n"],"names":["hasBufferAlloc","Buffer","alloc","hasBufferAllocUnsafe","allocUnsafe","hasBufferFrom","from","Uint8Array","allocBuffer","size","buf","fill","allocBufferUnsafe","bufferFrom","data","encoding","arr","i","length","push","bufferCompare","source","target","targetStart","targetEnd","sourceStart","sourceEnd","compare","sourceLen","targetLen","len","Math","min","s","t","bufferEquals","offset","expected","bufferSliceCopy","start","end","result","copy","readUInt64LE","low","readUInt32LE","high","writeUInt64LE","value","writeUInt32LE","bufferConcat","list","totalLength","actualLength","targetLength","undefined","allBuffers","j","concat","k","l","isNaN"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,+CAA+C;AAC/C,IAAIA,iBAAiB,OAAOC,OAAOC,KAAK,KAAK;AAC7C,IAAIC,uBAAuB,OAAOF,OAAOG,WAAW,KAAK;AACzD,IAAIC,gBAAgB,OAAOJ,OAAOK,IAAI,KAAK,cAAcL,OAAOK,IAAI,KAAKC,WAAWD,IAAI;AAExF;;;;CAIC,GACD,OAAO,SAASE,YAAYC,IAAY;IACtC,IAAIT,gBAAgB;QAClB,OAAOC,OAAOC,KAAK,CAACO;IACtB;IACA,iEAAiE;IACjE,IAAIC,MAAM,IAAIT,OAAOQ;IACrBC,IAAIC,IAAI,CAAC;IACT,OAAOD;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASE,kBAAkBH,IAAY;IAC5C,IAAIN,sBAAsB;QACxB,OAAOF,OAAOG,WAAW,CAACK;IAC5B;IACA,OAAO,IAAIR,OAAOQ;AACpB;AAEA;;;;;CAKC,GACD,OAAO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D,IAAIG,aAAa;IACjB,IAAK,IAAIC,IAAI,GAAGA,IAAIN,KAAKjC,MAAM,EAAEuC,IAAK;QACpC,IAAI,CAAEN,CAAAA,IAAI,CAACM,EAAE,YAAYxD,MAAK,GAAI;YAChCuD,aAAa;YACb;QACF;IACF;IACA,IAAIA,cAAcF,gBAAgBD,cAAc;QAC9C,OAAOpD,OAAOyD,MAAM,CAACP,MAAkBG;IACzC;IAEA,6DAA6D;IAC7D,IAAIb,SAASjC,YAAY8C;IACzB,IAAIlB,SAAS;IACb,IAAK,IAAIuB,IAAI,GAAGA,IAAIR,KAAKjC,MAAM,IAAIkB,SAASkB,cAAcK,IAAK;QAC7D,IAAIjD,MAAMyC,IAAI,CAACQ,EAAE;QACjB,IAAK,IAAIC,IAAI,GAAGA,IAAIlD,IAAIQ,MAAM,IAAIkB,SAASkB,cAAcM,IAAK;YAC5DnB,MAAM,CAACL,SAAS,GAAG1B,GAAG,CAACkD,EAAE;QAC3B;IACF;IACA,OAAOnB;AACT;AAEA;;;CAGC,GACD,6EAA6E;AAC7E,OAAO,SAASoB,MAAMb,KAAa;IACjC,gEAAgE;IAChE,OAAOA,UAAUA;AACnB"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * CRC32 calculation for archive formats
3
+ *
4
+ * Uses IEEE polynomial 0xEDB88320 (same as ZIP, 7z, PNG, gzip, etc.)
5
+ * All bit operations (>>>, ^, &) work correctly in Node 0.8
6
+ *
7
+ * This is the standard CRC-32 algorithm used by:
8
+ * - ZIP/PKZIP
9
+ * - 7-Zip
10
+ * - PNG
11
+ * - gzip
12
+ * - Ethernet
13
+ */
14
+ /**
15
+ * Calculate CRC32 of a buffer
16
+ * @param buf - Buffer to calculate CRC32 for
17
+ * @param initial - Optional initial CRC value (for streaming calculation)
18
+ * @returns CRC32 value as unsigned 32-bit integer
19
+ */
20
+ export declare function crc32(buf: Buffer, initial?: number): number;
21
+ /**
22
+ * Calculate CRC32 of a buffer region
23
+ * @param buf - Buffer containing data
24
+ * @param offset - Start offset in buffer
25
+ * @param length - Number of bytes to process
26
+ * @param initial - Optional initial CRC value
27
+ * @returns CRC32 value as unsigned 32-bit integer
28
+ */
29
+ export declare function crc32Region(buf: Buffer, offset: number, length: number, initial?: number): number;
30
+ /**
31
+ * Verify CRC32 matches expected value
32
+ * @param buf - Buffer to verify
33
+ * @param expected - Expected CRC32 value
34
+ * @returns true if CRC matches, false otherwise
35
+ */
36
+ export declare function verifyCrc32(buf: Buffer, expected: number): boolean;
37
+ /**
38
+ * Verify CRC32 of a buffer region matches expected value
39
+ * @param buf - Buffer containing data
40
+ * @param offset - Start offset in buffer
41
+ * @param length - Number of bytes to verify
42
+ * @param expected - Expected CRC32 value
43
+ * @returns true if CRC matches, false otherwise
44
+ */
45
+ export declare function verifyCrc32Region(buf: Buffer, offset: number, length: number, expected: number): boolean;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * CRC32 calculation for archive formats
3
+ *
4
+ * Uses IEEE polynomial 0xEDB88320 (same as ZIP, 7z, PNG, gzip, etc.)
5
+ * All bit operations (>>>, ^, &) work correctly in Node 0.8
6
+ *
7
+ * This is the standard CRC-32 algorithm used by:
8
+ * - ZIP/PKZIP
9
+ * - 7-Zip
10
+ * - PNG
11
+ * - gzip
12
+ * - Ethernet
13
+ */ // Pre-computed lookup table for performance
14
+ var CRC32_TABLE = [];
15
+ // Initialize table at module load time
16
+ (function initTable() {
17
+ for(var i = 0; i < 256; i++){
18
+ var c = i;
19
+ for(var j = 0; j < 8; j++){
20
+ if ((c & 1) !== 0) {
21
+ c = 0xedb88320 ^ c >>> 1;
22
+ } else {
23
+ c = c >>> 1;
24
+ }
25
+ }
26
+ CRC32_TABLE[i] = c >>> 0; // Ensure unsigned
27
+ }
28
+ })();
29
+ /**
30
+ * Calculate CRC32 of a buffer
31
+ * @param buf - Buffer to calculate CRC32 for
32
+ * @param initial - Optional initial CRC value (for streaming calculation)
33
+ * @returns CRC32 value as unsigned 32-bit integer
34
+ */ export function crc32(buf, initial) {
35
+ var crc = initial === undefined ? 0xffffffff : ~initial >>> 0;
36
+ for(var i = 0; i < buf.length; i++){
37
+ var index = (crc ^ buf[i]) & 0xff;
38
+ crc = CRC32_TABLE[index] ^ crc >>> 8;
39
+ }
40
+ return ~crc >>> 0; // Return unsigned
41
+ }
42
+ /**
43
+ * Calculate CRC32 of a buffer region
44
+ * @param buf - Buffer containing data
45
+ * @param offset - Start offset in buffer
46
+ * @param length - Number of bytes to process
47
+ * @param initial - Optional initial CRC value
48
+ * @returns CRC32 value as unsigned 32-bit integer
49
+ */ export function crc32Region(buf, offset, length, initial) {
50
+ var crc = initial === undefined ? 0xffffffff : ~initial >>> 0;
51
+ var end = offset + length;
52
+ for(var i = offset; i < end; i++){
53
+ var index = (crc ^ buf[i]) & 0xff;
54
+ crc = CRC32_TABLE[index] ^ crc >>> 8;
55
+ }
56
+ return ~crc >>> 0; // Return unsigned
57
+ }
58
+ /**
59
+ * Verify CRC32 matches expected value
60
+ * @param buf - Buffer to verify
61
+ * @param expected - Expected CRC32 value
62
+ * @returns true if CRC matches, false otherwise
63
+ */ export function verifyCrc32(buf, expected) {
64
+ return crc32(buf) === expected >>> 0;
65
+ }
66
+ /**
67
+ * Verify CRC32 of a buffer region matches expected value
68
+ * @param buf - Buffer containing data
69
+ * @param offset - Start offset in buffer
70
+ * @param length - Number of bytes to verify
71
+ * @param expected - Expected CRC32 value
72
+ * @returns true if CRC matches, false otherwise
73
+ */ export function verifyCrc32Region(buf, offset, length, expected) {
74
+ return crc32Region(buf, offset, length) === expected >>> 0;
75
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/extract-base-iterator/src/shared/crc32.ts"],"sourcesContent":["/**\n * CRC32 calculation for archive formats\n *\n * Uses IEEE polynomial 0xEDB88320 (same as ZIP, 7z, PNG, gzip, etc.)\n * All bit operations (>>>, ^, &) work correctly in Node 0.8\n *\n * This is the standard CRC-32 algorithm used by:\n * - ZIP/PKZIP\n * - 7-Zip\n * - PNG\n * - gzip\n * - Ethernet\n */\n\n// Pre-computed lookup table for performance\nvar CRC32_TABLE: number[] = [];\n\n// Initialize table at module load time\n(function initTable() {\n for (var i = 0; i < 256; i++) {\n var c = i;\n for (var j = 0; j < 8; j++) {\n if ((c & 1) !== 0) {\n c = 0xedb88320 ^ (c >>> 1);\n } else {\n c = c >>> 1;\n }\n }\n CRC32_TABLE[i] = c >>> 0; // Ensure unsigned\n }\n})();\n\n/**\n * Calculate CRC32 of a buffer\n * @param buf - Buffer to calculate CRC32 for\n * @param initial - Optional initial CRC value (for streaming calculation)\n * @returns CRC32 value as unsigned 32-bit integer\n */\nexport function crc32(buf: Buffer, initial?: number): number {\n var crc = initial === undefined ? 0xffffffff : ~initial >>> 0;\n\n for (var i = 0; i < buf.length; i++) {\n var index = (crc ^ buf[i]) & 0xff;\n crc = CRC32_TABLE[index] ^ (crc >>> 8);\n }\n\n return ~crc >>> 0; // Return unsigned\n}\n\n/**\n * Calculate CRC32 of a buffer region\n * @param buf - Buffer containing data\n * @param offset - Start offset in buffer\n * @param length - Number of bytes to process\n * @param initial - Optional initial CRC value\n * @returns CRC32 value as unsigned 32-bit integer\n */\nexport function crc32Region(buf: Buffer, offset: number, length: number, initial?: number): number {\n var crc = initial === undefined ? 0xffffffff : ~initial >>> 0;\n var end = offset + length;\n\n for (var i = offset; i < end; i++) {\n var index = (crc ^ buf[i]) & 0xff;\n crc = CRC32_TABLE[index] ^ (crc >>> 8);\n }\n\n return ~crc >>> 0; // Return unsigned\n}\n\n/**\n * Verify CRC32 matches expected value\n * @param buf - Buffer to verify\n * @param expected - Expected CRC32 value\n * @returns true if CRC matches, false otherwise\n */\nexport function verifyCrc32(buf: Buffer, expected: number): boolean {\n return crc32(buf) === expected >>> 0;\n}\n\n/**\n * Verify CRC32 of a buffer region matches expected value\n * @param buf - Buffer containing data\n * @param offset - Start offset in buffer\n * @param length - Number of bytes to verify\n * @param expected - Expected CRC32 value\n * @returns true if CRC matches, false otherwise\n */\nexport function verifyCrc32Region(buf: Buffer, offset: number, length: number, expected: number): boolean {\n return crc32Region(buf, offset, length) === expected >>> 0;\n}\n"],"names":["CRC32_TABLE","initTable","i","c","j","crc32","buf","initial","crc","undefined","length","index","crc32Region","offset","end","verifyCrc32","expected","verifyCrc32Region"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAED,4CAA4C;AAC5C,IAAIA,cAAwB,EAAE;AAE9B,uCAAuC;AACtC,CAAA,SAASC;IACR,IAAK,IAAIC,IAAI,GAAGA,IAAI,KAAKA,IAAK;QAC5B,IAAIC,IAAID;QACR,IAAK,IAAIE,IAAI,GAAGA,IAAI,GAAGA,IAAK;YAC1B,IAAI,AAACD,CAAAA,IAAI,CAAA,MAAO,GAAG;gBACjBA,IAAI,aAAcA,MAAM;YAC1B,OAAO;gBACLA,IAAIA,MAAM;YACZ;QACF;QACAH,WAAW,CAACE,EAAE,GAAGC,MAAM,GAAG,kBAAkB;IAC9C;AACF,CAAA;AAEA;;;;;CAKC,GACD,OAAO,SAASE,MAAMC,GAAW,EAAEC,OAAgB;IACjD,IAAIC,MAAMD,YAAYE,YAAY,aAAa,CAACF,YAAY;IAE5D,IAAK,IAAIL,IAAI,GAAGA,IAAII,IAAII,MAAM,EAAER,IAAK;QACnC,IAAIS,QAAQ,AAACH,CAAAA,MAAMF,GAAG,CAACJ,EAAE,AAAD,IAAK;QAC7BM,MAAMR,WAAW,CAACW,MAAM,GAAIH,QAAQ;IACtC;IAEA,OAAO,CAACA,QAAQ,GAAG,kBAAkB;AACvC;AAEA;;;;;;;CAOC,GACD,OAAO,SAASI,YAAYN,GAAW,EAAEO,MAAc,EAAEH,MAAc,EAAEH,OAAgB;IACvF,IAAIC,MAAMD,YAAYE,YAAY,aAAa,CAACF,YAAY;IAC5D,IAAIO,MAAMD,SAASH;IAEnB,IAAK,IAAIR,IAAIW,QAAQX,IAAIY,KAAKZ,IAAK;QACjC,IAAIS,QAAQ,AAACH,CAAAA,MAAMF,GAAG,CAACJ,EAAE,AAAD,IAAK;QAC7BM,MAAMR,WAAW,CAACW,MAAM,GAAIH,QAAQ;IACtC;IAEA,OAAO,CAACA,QAAQ,GAAG,kBAAkB;AACvC;AAEA;;;;;CAKC,GACD,OAAO,SAASO,YAAYT,GAAW,EAAEU,QAAgB;IACvD,OAAOX,MAAMC,SAASU,aAAa;AACrC;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC,kBAAkBX,GAAW,EAAEO,MAAc,EAAEH,MAAc,EAAEM,QAAgB;IAC7F,OAAOJ,YAAYN,KAAKO,QAAQH,YAAYM,aAAa;AAC3D"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shared utilities for iterator libraries
3
+ *
4
+ * These utilities are designed to be used by:
5
+ * - zip-iterator
6
+ * - 7z-iterator
7
+ * - tar-iterator
8
+ * - Any other archive iterator library
9
+ *
10
+ * All utilities support Node.js 0.8+
11
+ */
12
+ export { allocBuffer, allocBufferUnsafe, bufferCompare, bufferConcat, bufferEquals, bufferFrom, bufferSliceCopy, isNaN, readUInt64LE, writeUInt64LE, } from './compat.js';
13
+ export { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.js';
14
+ export { default as EntryStream } from './EntryStream.js';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Shared utilities for iterator libraries
3
+ *
4
+ * These utilities are designed to be used by:
5
+ * - zip-iterator
6
+ * - 7z-iterator
7
+ * - tar-iterator
8
+ * - Any other archive iterator library
9
+ *
10
+ * All utilities support Node.js 0.8+
11
+ */ export { allocBuffer, allocBufferUnsafe, bufferCompare, bufferConcat, bufferEquals, bufferFrom, bufferSliceCopy, isNaN, readUInt64LE, writeUInt64LE } from './compat.js';
12
+ export { crc32, crc32Region, verifyCrc32, verifyCrc32Region } from './crc32.js';
13
+ export { default as EntryStream } from './EntryStream.js';
@@ -0,0 +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\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.2.6",
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",
@@ -36,6 +36,7 @@
36
36
  "scripts": {
37
37
  "build": "tsds build",
38
38
  "format": "biome check --write --unsafe",
39
+ "prepublishOnly": "tsds validate",
39
40
  "test": "mocha --no-timeouts test/**/*.test.*",
40
41
  "test:engines": "nvu engines tsds test:node --no-timeouts",
41
42
  "version": "tsds version"