tar-iterator 3.0.1 → 3.1.0
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/TarIterator.js +8 -6
- package/dist/cjs/TarIterator.js.map +1 -1
- package/dist/cjs/lib/Lock.d.cts +4 -0
- package/dist/cjs/lib/Lock.d.ts +4 -0
- package/dist/cjs/lib/Lock.js +14 -0
- package/dist/cjs/lib/Lock.js.map +1 -1
- package/dist/cjs/nextEntry.js +10 -1
- package/dist/cjs/nextEntry.js.map +1 -1
- package/dist/cjs/tar/TarExtract.js +3 -3
- package/dist/cjs/tar/TarExtract.js.map +1 -1
- package/dist/cjs/tar/index.d.cts +1 -1
- package/dist/cjs/tar/index.d.ts +1 -1
- package/dist/cjs/tar/index.js +2 -2
- package/dist/cjs/tar/index.js.map +1 -1
- package/dist/cjs/tar/sparse.js +3 -4
- package/dist/cjs/tar/sparse.js.map +1 -1
- package/dist/esm/TarIterator.js +8 -6
- package/dist/esm/TarIterator.js.map +1 -1
- package/dist/esm/lib/Lock.d.ts +4 -0
- package/dist/esm/lib/Lock.js +14 -0
- package/dist/esm/lib/Lock.js.map +1 -1
- package/dist/esm/nextEntry.js +10 -1
- package/dist/esm/nextEntry.js.map +1 -1
- package/dist/esm/tar/TarExtract.js +2 -2
- package/dist/esm/tar/TarExtract.js.map +1 -1
- package/dist/esm/tar/index.d.ts +1 -1
- package/dist/esm/tar/index.js +1 -1
- package/dist/esm/tar/index.js.map +1 -1
- package/dist/esm/tar/sparse.js +4 -5
- package/dist/esm/tar/sparse.js.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/tar/BufferList.d.cts +0 -31
- package/dist/cjs/tar/BufferList.d.ts +0 -31
- package/dist/cjs/tar/BufferList.js +0 -104
- package/dist/cjs/tar/BufferList.js.map +0 -1
- package/dist/esm/tar/BufferList.d.ts +0 -31
- package/dist/esm/tar/BufferList.js +0 -85
- package/dist/esm/tar/BufferList.js.map +0 -1
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BufferList - Simple linked list for buffering streaming data
|
|
3
|
-
*
|
|
4
|
-
* Node 0.8 compatible - uses only basic Buffer APIs:
|
|
5
|
-
* - new Buffer(size)
|
|
6
|
-
* - Buffer.copy(target, targetStart, sourceStart, sourceEnd)
|
|
7
|
-
* - Buffer.slice(start, end)
|
|
8
|
-
* - Buffer.length
|
|
9
|
-
*/
|
|
10
|
-
export default class BufferList {
|
|
11
|
-
private head;
|
|
12
|
-
private tail;
|
|
13
|
-
length: number;
|
|
14
|
-
/**
|
|
15
|
-
* Append a buffer to the end of the list
|
|
16
|
-
*/
|
|
17
|
-
append(buf: Buffer): void;
|
|
18
|
-
/**
|
|
19
|
-
* Consume and return n bytes from the front
|
|
20
|
-
* Returns a new buffer containing the consumed bytes
|
|
21
|
-
*/
|
|
22
|
-
consume(n: number): Buffer;
|
|
23
|
-
/**
|
|
24
|
-
* Clear all buffered data
|
|
25
|
-
*/
|
|
26
|
-
clear(): void;
|
|
27
|
-
/**
|
|
28
|
-
* Check if buffer has at least n bytes available
|
|
29
|
-
*/
|
|
30
|
-
has(n: number): boolean;
|
|
31
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BufferList - Simple linked list for buffering streaming data
|
|
3
|
-
*
|
|
4
|
-
* Node 0.8 compatible - uses only basic Buffer APIs:
|
|
5
|
-
* - new Buffer(size)
|
|
6
|
-
* - Buffer.copy(target, targetStart, sourceStart, sourceEnd)
|
|
7
|
-
* - Buffer.slice(start, end)
|
|
8
|
-
* - Buffer.length
|
|
9
|
-
*/ let BufferList = class BufferList {
|
|
10
|
-
/**
|
|
11
|
-
* Append a buffer to the end of the list
|
|
12
|
-
*/ append(buf) {
|
|
13
|
-
const node = {
|
|
14
|
-
data: buf,
|
|
15
|
-
next: null
|
|
16
|
-
};
|
|
17
|
-
if (this.tail) {
|
|
18
|
-
this.tail.next = node;
|
|
19
|
-
this.tail = node;
|
|
20
|
-
} else {
|
|
21
|
-
this.head = node;
|
|
22
|
-
this.tail = node;
|
|
23
|
-
}
|
|
24
|
-
this.length += buf.length;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Consume and return n bytes from the front
|
|
28
|
-
* Returns a new buffer containing the consumed bytes
|
|
29
|
-
*/ consume(n) {
|
|
30
|
-
if (n > this.length) {
|
|
31
|
-
throw new Error('Not enough data in buffer');
|
|
32
|
-
}
|
|
33
|
-
if (n === 0) {
|
|
34
|
-
// Return empty buffer - use new Buffer for Node 0.8 compat
|
|
35
|
-
return new Buffer(0);
|
|
36
|
-
}
|
|
37
|
-
// Allocate result buffer
|
|
38
|
-
const result = new Buffer(n);
|
|
39
|
-
let resultOffset = 0;
|
|
40
|
-
let remaining = n;
|
|
41
|
-
while(remaining > 0 && this.head){
|
|
42
|
-
const chunk = this.head.data;
|
|
43
|
-
const available = chunk.length;
|
|
44
|
-
if (available <= remaining) {
|
|
45
|
-
// Consume entire chunk
|
|
46
|
-
chunk.copy(result, resultOffset, 0, available);
|
|
47
|
-
resultOffset += available;
|
|
48
|
-
remaining -= available;
|
|
49
|
-
this.length -= available;
|
|
50
|
-
// Move to next node
|
|
51
|
-
this.head = this.head.next;
|
|
52
|
-
if (!this.head) {
|
|
53
|
-
this.tail = null;
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
// Consume partial chunk
|
|
57
|
-
chunk.copy(result, resultOffset, 0, remaining);
|
|
58
|
-
resultOffset += remaining;
|
|
59
|
-
this.length -= remaining;
|
|
60
|
-
// Keep remainder of chunk
|
|
61
|
-
this.head.data = chunk.slice(remaining);
|
|
62
|
-
remaining = 0;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Clear all buffered data
|
|
69
|
-
*/ clear() {
|
|
70
|
-
this.head = null;
|
|
71
|
-
this.tail = null;
|
|
72
|
-
this.length = 0;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Check if buffer has at least n bytes available
|
|
76
|
-
*/ has(n) {
|
|
77
|
-
return this.length >= n;
|
|
78
|
-
}
|
|
79
|
-
constructor(){
|
|
80
|
-
this.head = null;
|
|
81
|
-
this.tail = null;
|
|
82
|
-
this.length = 0;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
export { BufferList as default };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/tar-iterator/src/tar/BufferList.ts"],"sourcesContent":["/**\n * BufferList - Simple linked list for buffering streaming data\n *\n * Node 0.8 compatible - uses only basic Buffer APIs:\n * - new Buffer(size)\n * - Buffer.copy(target, targetStart, sourceStart, sourceEnd)\n * - Buffer.slice(start, end)\n * - Buffer.length\n */\n\ninterface BufferNode {\n data: Buffer;\n next: BufferNode | null;\n}\n\nexport default class BufferList {\n private head: BufferNode | null = null;\n private tail: BufferNode | null = null;\n length = 0;\n\n /**\n * Append a buffer to the end of the list\n */\n append(buf: Buffer): void {\n const node: BufferNode = { data: buf, next: null };\n\n if (this.tail) {\n this.tail.next = node;\n this.tail = node;\n } else {\n this.head = node;\n this.tail = node;\n }\n\n this.length += buf.length;\n }\n\n /**\n * Consume and return n bytes from the front\n * Returns a new buffer containing the consumed bytes\n */\n consume(n: number): Buffer {\n if (n > this.length) {\n throw new Error('Not enough data in buffer');\n }\n\n if (n === 0) {\n // Return empty buffer - use new Buffer for Node 0.8 compat\n return new Buffer(0);\n }\n\n // Allocate result buffer\n const result = new Buffer(n);\n let resultOffset = 0;\n let remaining = n;\n\n while (remaining > 0 && this.head) {\n const chunk = this.head.data;\n const available = chunk.length;\n\n if (available <= remaining) {\n // Consume entire chunk\n chunk.copy(result, resultOffset, 0, available);\n resultOffset += available;\n remaining -= available;\n this.length -= available;\n\n // Move to next node\n this.head = this.head.next;\n if (!this.head) {\n this.tail = null;\n }\n } else {\n // Consume partial chunk\n chunk.copy(result, resultOffset, 0, remaining);\n resultOffset += remaining;\n this.length -= remaining;\n\n // Keep remainder of chunk\n this.head.data = chunk.slice(remaining);\n remaining = 0;\n }\n }\n\n return result;\n }\n\n /**\n * Clear all buffered data\n */\n clear(): void {\n this.head = null;\n this.tail = null;\n this.length = 0;\n }\n\n /**\n * Check if buffer has at least n bytes available\n */\n has(n: number): boolean {\n return this.length >= n;\n }\n}\n"],"names":["BufferList","append","buf","node","data","next","tail","head","length","consume","n","Error","Buffer","result","resultOffset","remaining","chunk","available","copy","slice","clear","has"],"mappings":"AAAA;;;;;;;;CAQC,GAOc,IAAA,AAAMA,aAAN,MAAMA;IAKnB;;GAEC,GACDC,OAAOC,GAAW,EAAQ;QACxB,MAAMC,OAAmB;YAAEC,MAAMF;YAAKG,MAAM;QAAK;QAEjD,IAAI,IAAI,CAACC,IAAI,EAAE;YACb,IAAI,CAACA,IAAI,CAACD,IAAI,GAAGF;YACjB,IAAI,CAACG,IAAI,GAAGH;QACd,OAAO;YACL,IAAI,CAACI,IAAI,GAAGJ;YACZ,IAAI,CAACG,IAAI,GAAGH;QACd;QAEA,IAAI,CAACK,MAAM,IAAIN,IAAIM,MAAM;IAC3B;IAEA;;;GAGC,GACDC,QAAQC,CAAS,EAAU;QACzB,IAAIA,IAAI,IAAI,CAACF,MAAM,EAAE;YACnB,MAAM,IAAIG,MAAM;QAClB;QAEA,IAAID,MAAM,GAAG;YACX,2DAA2D;YAC3D,OAAO,IAAIE,OAAO;QACpB;QAEA,yBAAyB;QACzB,MAAMC,SAAS,IAAID,OAAOF;QAC1B,IAAII,eAAe;QACnB,IAAIC,YAAYL;QAEhB,MAAOK,YAAY,KAAK,IAAI,CAACR,IAAI,CAAE;YACjC,MAAMS,QAAQ,IAAI,CAACT,IAAI,CAACH,IAAI;YAC5B,MAAMa,YAAYD,MAAMR,MAAM;YAE9B,IAAIS,aAAaF,WAAW;gBAC1B,uBAAuB;gBACvBC,MAAME,IAAI,CAACL,QAAQC,cAA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