node-pkware 4.0.0-alpha.8 → 4.0.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/README.md +2 -8
- package/dist/Explode.d.ts +37 -1
- package/dist/Explode.js +164 -148
- package/dist/Explode.js.map +1 -1
- package/dist/Implode.d.ts +34 -4
- package/dist/Implode.js +167 -145
- package/dist/Implode.js.map +1 -1
- package/dist/bin/explode.js +1 -3
- package/dist/bin/explode.js.map +1 -1
- package/dist/bin/implode.js +1 -3
- package/dist/bin/implode.js.map +1 -1
- package/dist/errors.d.ts +0 -9
- package/dist/errors.js +0 -12
- package/dist/errors.js.map +1 -1
- package/dist/types.d.ts +0 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,9 +69,7 @@ Takes an optional config object, which has the following properties:
|
|
|
69
69
|
|
|
70
70
|
```js
|
|
71
71
|
{
|
|
72
|
-
verbose: boolean
|
|
73
|
-
inputBufferSize: int, // the starting size of the input buffer, may expand later as needed. Not having to expand may have positive performance impact (default 0)
|
|
74
|
-
outputBufferSize: int // same as inputBufferSize, but for the outputBuffer (default 0)
|
|
72
|
+
verbose: boolean // whether the code should display extra debug messages on the console or not (default = false)
|
|
75
73
|
}
|
|
76
74
|
```
|
|
77
75
|
|
|
@@ -83,9 +81,7 @@ Takes an optional config object, which has the following properties:
|
|
|
83
81
|
|
|
84
82
|
```js
|
|
85
83
|
{
|
|
86
|
-
verbose: boolean
|
|
87
|
-
inputBufferSize: int, // the starting size of the input buffer, may expand later as needed. Not having to expand may have positive performance impact (default 0)
|
|
88
|
-
outputBufferSize: int // same as inputBufferSize, but for the outputBuffer (default 0)
|
|
84
|
+
verbose: boolean // whether the code should display extra debug messages on the console or not (default = false)
|
|
89
85
|
}
|
|
90
86
|
```
|
|
91
87
|
|
|
@@ -122,8 +118,6 @@ The returned function has the `(chunk: Buffer, encoding: string, callback: funct
|
|
|
122
118
|
|
|
123
119
|
`errors.InvalidCompressionTypeError` - thrown by implode when invalid compression type was specified or by explode when it encounters invalid data in the header section (the first 2 bytes of a compressed files)
|
|
124
120
|
|
|
125
|
-
`errors.InvalidDataError` - thrown by explode, when compressed data is less, than 5 bytes long. Pkware compressed files have 2 bytes header followed by at lest 2 bytes of data and an end literal.
|
|
126
|
-
|
|
127
121
|
`errors.AbortedError` - thrown by explode when compressed data ends without reaching the end literal or in mid decompression
|
|
128
122
|
|
|
129
123
|
### examples
|
package/dist/Explode.d.ts
CHANGED
|
@@ -2,7 +2,43 @@ import { Buffer } from 'node:buffer';
|
|
|
2
2
|
import { type Transform, type TransformCallback } from 'node:stream';
|
|
3
3
|
import { type Config } from './types.js';
|
|
4
4
|
export declare class Explode {
|
|
5
|
-
|
|
5
|
+
private readonly verbose;
|
|
6
|
+
private needMoreInput;
|
|
7
|
+
private isFirstChunk;
|
|
8
|
+
private extraBits;
|
|
9
|
+
private bitBuffer;
|
|
10
|
+
private readonly backupData;
|
|
11
|
+
private readonly lengthCodes;
|
|
12
|
+
private readonly distPosCodes;
|
|
13
|
+
private readonly inputBuffer;
|
|
14
|
+
private readonly outputBuffer;
|
|
15
|
+
private readonly stats;
|
|
16
|
+
private compressionType;
|
|
17
|
+
private dictionarySize;
|
|
18
|
+
private dictionarySizeMask;
|
|
19
|
+
private chBitsAsc;
|
|
20
|
+
private asciiTable2C34;
|
|
21
|
+
private asciiTable2D34;
|
|
22
|
+
private asciiTable2E34;
|
|
23
|
+
private asciiTable2EB4;
|
|
6
24
|
constructor(config?: Config);
|
|
7
25
|
getHandler(): (this: Transform, chunk: Buffer, encoding: BufferEncoding, callback: TransformCallback) => void;
|
|
26
|
+
private generateAsciiTables;
|
|
27
|
+
private onInputFinished;
|
|
28
|
+
/**
|
|
29
|
+
* @throws {@link AbortedError} when there isn't enough data to be wasted
|
|
30
|
+
*/
|
|
31
|
+
private wasteBits;
|
|
32
|
+
/**
|
|
33
|
+
* @throws {@link AbortedError}
|
|
34
|
+
*/
|
|
35
|
+
private decodeNextLiteral;
|
|
36
|
+
/**
|
|
37
|
+
* @throws {@link AbortedError}
|
|
38
|
+
*/
|
|
39
|
+
private decodeDistance;
|
|
40
|
+
private processChunkData;
|
|
41
|
+
private parseInitialData;
|
|
42
|
+
private backup;
|
|
43
|
+
private restore;
|
|
8
44
|
}
|
package/dist/Explode.js
CHANGED
|
@@ -6,7 +6,7 @@ import { quotientAndRemainder, getLowestNBitsOf, mergeSparseArrays, nBitsOfOnes,
|
|
|
6
6
|
/**
|
|
7
7
|
* This function assumes there are at least 2 bytes of data in the buffer
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
function readHeader(buffer) {
|
|
10
10
|
const compressionType = buffer.readUInt8(0);
|
|
11
11
|
const dictionarySize = buffer.readUInt8(1);
|
|
12
12
|
if (!(compressionType in Compression) || compressionType === Compression.Unknown) {
|
|
@@ -19,235 +19,251 @@ const readHeader = (buffer) => {
|
|
|
19
19
|
compressionType: compressionType,
|
|
20
20
|
dictionarySize: dictionarySize,
|
|
21
21
|
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const codes = repeat(0,
|
|
22
|
+
}
|
|
23
|
+
function generateDecodeTables(startIndexes, lengthBits) {
|
|
24
|
+
const codes = repeat(0, 0x1_00);
|
|
25
25
|
lengthBits.forEach((lengthBit, i) => {
|
|
26
|
-
for (let index = startIndexes[i]; index <
|
|
26
|
+
for (let index = startIndexes[i]; index < 0x1_00; index = index + (1 << lengthBit)) {
|
|
27
27
|
codes[index] = i;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
return codes;
|
|
31
|
-
}
|
|
31
|
+
}
|
|
32
32
|
/**
|
|
33
33
|
* PAT = populate ascii table
|
|
34
34
|
*/
|
|
35
|
-
|
|
36
|
-
return (n)
|
|
37
|
-
|
|
35
|
+
function createPATIterator(limit, stepper) {
|
|
36
|
+
return function (n) {
|
|
37
|
+
if (n >= limit) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return [n, n + (1 << stepper)];
|
|
38
41
|
};
|
|
39
|
-
}
|
|
40
|
-
|
|
42
|
+
}
|
|
43
|
+
function populateAsciiTable(value, index, bits, limit) {
|
|
41
44
|
const iterator = createPATIterator(limit, value - bits);
|
|
42
45
|
const seed = ChCodeAsc[index] >> bits;
|
|
43
|
-
const
|
|
46
|
+
const indices = unfold(iterator, seed);
|
|
44
47
|
const table = [];
|
|
45
|
-
|
|
48
|
+
indices.forEach((idx) => {
|
|
46
49
|
table[idx] = index;
|
|
47
50
|
});
|
|
48
51
|
return table;
|
|
49
|
-
}
|
|
52
|
+
}
|
|
50
53
|
export class Explode {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
#asciiTable2D34 = repeat(0, 0x100);
|
|
71
|
-
#asciiTable2E34 = repeat(0, 0x80);
|
|
72
|
-
#asciiTable2EB4 = repeat(0, 0x100);
|
|
54
|
+
verbose;
|
|
55
|
+
needMoreInput;
|
|
56
|
+
isFirstChunk;
|
|
57
|
+
extraBits;
|
|
58
|
+
bitBuffer;
|
|
59
|
+
backupData;
|
|
60
|
+
lengthCodes;
|
|
61
|
+
distPosCodes;
|
|
62
|
+
inputBuffer;
|
|
63
|
+
outputBuffer;
|
|
64
|
+
stats;
|
|
65
|
+
compressionType;
|
|
66
|
+
dictionarySize;
|
|
67
|
+
dictionarySizeMask;
|
|
68
|
+
chBitsAsc;
|
|
69
|
+
asciiTable2C34;
|
|
70
|
+
asciiTable2D34;
|
|
71
|
+
asciiTable2E34;
|
|
72
|
+
asciiTable2EB4;
|
|
73
73
|
constructor(config = {}) {
|
|
74
|
-
this
|
|
75
|
-
this
|
|
76
|
-
this
|
|
74
|
+
this.verbose = config?.verbose ?? false;
|
|
75
|
+
this.needMoreInput = true;
|
|
76
|
+
this.isFirstChunk = true;
|
|
77
|
+
this.extraBits = 0;
|
|
78
|
+
this.bitBuffer = 0;
|
|
79
|
+
this.backupData = { extraBits: -1, bitBuffer: -1 };
|
|
80
|
+
this.lengthCodes = generateDecodeTables(LenCode, LenBits);
|
|
81
|
+
this.distPosCodes = generateDecodeTables(DistCode, DistBits);
|
|
82
|
+
this.inputBuffer = new ExpandingBuffer(0x1_00_00);
|
|
83
|
+
this.outputBuffer = new ExpandingBuffer(0x4_00_00);
|
|
84
|
+
this.stats = { chunkCounter: 0 };
|
|
85
|
+
this.compressionType = Compression.Unknown;
|
|
86
|
+
this.dictionarySize = DictionarySize.Unknown;
|
|
87
|
+
this.dictionarySizeMask = 0;
|
|
88
|
+
this.chBitsAsc = repeat(0, 0x1_00);
|
|
89
|
+
this.asciiTable2C34 = repeat(0, 0x1_00);
|
|
90
|
+
this.asciiTable2D34 = repeat(0, 0x1_00);
|
|
91
|
+
this.asciiTable2E34 = repeat(0, 0x80);
|
|
92
|
+
this.asciiTable2EB4 = repeat(0, 0x1_00);
|
|
77
93
|
}
|
|
78
94
|
getHandler() {
|
|
79
95
|
const instance = this;
|
|
80
96
|
return function (chunk, encoding, callback) {
|
|
81
|
-
instance
|
|
97
|
+
instance.needMoreInput = true;
|
|
82
98
|
try {
|
|
83
|
-
instance
|
|
84
|
-
if (instance
|
|
85
|
-
instance
|
|
86
|
-
this._flush = instance
|
|
99
|
+
instance.inputBuffer.append(chunk);
|
|
100
|
+
if (instance.isFirstChunk) {
|
|
101
|
+
instance.isFirstChunk = false;
|
|
102
|
+
this._flush = instance.onInputFinished.bind(instance);
|
|
87
103
|
}
|
|
88
|
-
if (instance
|
|
89
|
-
instance
|
|
90
|
-
console.log(`explode: reading ${toHex(chunk.length)} bytes from chunk #${instance
|
|
104
|
+
if (instance.verbose) {
|
|
105
|
+
instance.stats.chunkCounter = instance.stats.chunkCounter + 1;
|
|
106
|
+
console.log(`explode: reading ${toHex(chunk.length)} bytes from chunk #${instance.stats.chunkCounter}`);
|
|
91
107
|
}
|
|
92
|
-
instance
|
|
93
|
-
const blockSize =
|
|
94
|
-
if (instance
|
|
108
|
+
instance.processChunkData();
|
|
109
|
+
const blockSize = 0x10_00;
|
|
110
|
+
if (instance.outputBuffer.size() <= blockSize) {
|
|
95
111
|
callback(null, EMPTY_BUFFER);
|
|
96
112
|
return;
|
|
97
113
|
}
|
|
98
|
-
let [numberOfBlocks] = quotientAndRemainder(instance
|
|
114
|
+
let [numberOfBlocks] = quotientAndRemainder(instance.outputBuffer.size(), blockSize);
|
|
99
115
|
// making sure to leave one block worth of data for lookback when processing chunk data
|
|
100
|
-
numberOfBlocks
|
|
116
|
+
numberOfBlocks = numberOfBlocks - 1;
|
|
101
117
|
const numberOfBytes = numberOfBlocks * blockSize;
|
|
102
118
|
// make sure to create a copy of the output buffer slice as it will get flushed in the next line
|
|
103
|
-
const output = Buffer.from(instance
|
|
104
|
-
instance
|
|
119
|
+
const output = Buffer.from(instance.outputBuffer.read(0, numberOfBytes));
|
|
120
|
+
instance.outputBuffer.flushStart(numberOfBytes);
|
|
105
121
|
callback(null, output);
|
|
106
122
|
}
|
|
107
|
-
catch (
|
|
108
|
-
callback(
|
|
123
|
+
catch (error) {
|
|
124
|
+
callback(error);
|
|
109
125
|
}
|
|
110
126
|
};
|
|
111
127
|
}
|
|
112
|
-
|
|
113
|
-
this
|
|
128
|
+
generateAsciiTables() {
|
|
129
|
+
this.chBitsAsc = ChBitsAsc.map((value, index) => {
|
|
114
130
|
if (value <= 8) {
|
|
115
|
-
this
|
|
131
|
+
this.asciiTable2C34 = mergeSparseArrays(populateAsciiTable(value, index, 0, 0x1_00), this.asciiTable2C34);
|
|
116
132
|
return value - 0;
|
|
117
133
|
}
|
|
118
134
|
const acc = getLowestNBitsOf(ChCodeAsc[index], 8);
|
|
119
135
|
if (acc === 0) {
|
|
120
|
-
this
|
|
136
|
+
this.asciiTable2EB4 = mergeSparseArrays(populateAsciiTable(value, index, 8, 0x1_00), this.asciiTable2EB4);
|
|
121
137
|
return value - 8;
|
|
122
138
|
}
|
|
123
|
-
this
|
|
139
|
+
this.asciiTable2C34[acc] = 0xff;
|
|
124
140
|
if (getLowestNBitsOf(acc, 6) === 0) {
|
|
125
|
-
this
|
|
141
|
+
this.asciiTable2E34 = mergeSparseArrays(populateAsciiTable(value, index, 6, 0x80), this.asciiTable2E34);
|
|
126
142
|
return value - 6;
|
|
127
143
|
}
|
|
128
|
-
this
|
|
144
|
+
this.asciiTable2D34 = mergeSparseArrays(populateAsciiTable(value, index, 4, 0x1_00), this.asciiTable2D34);
|
|
129
145
|
return value - 4;
|
|
130
146
|
});
|
|
131
147
|
}
|
|
132
|
-
|
|
133
|
-
if (this
|
|
148
|
+
onInputFinished(callback) {
|
|
149
|
+
if (this.verbose) {
|
|
134
150
|
console.log('---------------');
|
|
135
|
-
console.log('explode: total number of chunks read:', this
|
|
136
|
-
console.log('explode: inputBuffer heap size', toHex(this
|
|
137
|
-
console.log('explode: outputBuffer heap size', toHex(this
|
|
151
|
+
console.log('explode: total number of chunks read:', this.stats.chunkCounter);
|
|
152
|
+
console.log('explode: inputBuffer heap size', toHex(this.inputBuffer.heapSize()));
|
|
153
|
+
console.log('explode: outputBuffer heap size', toHex(this.outputBuffer.heapSize()));
|
|
138
154
|
}
|
|
139
|
-
if (this
|
|
155
|
+
if (this.needMoreInput) {
|
|
140
156
|
callback(new AbortedError());
|
|
141
157
|
return;
|
|
142
158
|
}
|
|
143
|
-
callback(null, this
|
|
159
|
+
callback(null, this.outputBuffer.read());
|
|
144
160
|
}
|
|
145
161
|
/**
|
|
146
162
|
* @throws {@link AbortedError} when there isn't enough data to be wasted
|
|
147
163
|
*/
|
|
148
|
-
|
|
149
|
-
if (numberOfBits > this
|
|
164
|
+
wasteBits(numberOfBits) {
|
|
165
|
+
if (numberOfBits > this.extraBits && this.inputBuffer.isEmpty()) {
|
|
150
166
|
throw new AbortedError();
|
|
151
167
|
}
|
|
152
|
-
if (numberOfBits <= this
|
|
153
|
-
this
|
|
154
|
-
this
|
|
168
|
+
if (numberOfBits <= this.extraBits) {
|
|
169
|
+
this.bitBuffer = this.bitBuffer >> numberOfBits;
|
|
170
|
+
this.extraBits = this.extraBits - numberOfBits;
|
|
155
171
|
return;
|
|
156
172
|
}
|
|
157
|
-
const nextByte = this
|
|
158
|
-
this
|
|
159
|
-
this
|
|
160
|
-
this
|
|
173
|
+
const nextByte = this.inputBuffer.readByte(0);
|
|
174
|
+
this.inputBuffer.dropStart(1);
|
|
175
|
+
this.bitBuffer = ((this.bitBuffer >> this.extraBits) | (nextByte << 8)) >> (numberOfBits - this.extraBits);
|
|
176
|
+
this.extraBits = this.extraBits + 8 - numberOfBits;
|
|
161
177
|
}
|
|
162
178
|
/**
|
|
163
179
|
* @throws {@link AbortedError}
|
|
164
180
|
*/
|
|
165
|
-
|
|
166
|
-
const lastBit = getLowestNBitsOf(this
|
|
167
|
-
this
|
|
181
|
+
decodeNextLiteral() {
|
|
182
|
+
const lastBit = getLowestNBitsOf(this.bitBuffer, 1);
|
|
183
|
+
this.wasteBits(1);
|
|
168
184
|
if (lastBit) {
|
|
169
|
-
let lengthCode = this
|
|
170
|
-
this
|
|
185
|
+
let lengthCode = this.lengthCodes[getLowestNBitsOf(this.bitBuffer, 8)];
|
|
186
|
+
this.wasteBits(LenBits[lengthCode]);
|
|
171
187
|
const extraLenghtBits = ExLenBits[lengthCode];
|
|
172
188
|
if (extraLenghtBits !== 0) {
|
|
173
|
-
const extraLength = getLowestNBitsOf(this
|
|
189
|
+
const extraLength = getLowestNBitsOf(this.bitBuffer, extraLenghtBits);
|
|
174
190
|
try {
|
|
175
|
-
this
|
|
191
|
+
this.wasteBits(extraLenghtBits);
|
|
176
192
|
}
|
|
177
|
-
catch
|
|
178
|
-
if (lengthCode + extraLength !==
|
|
193
|
+
catch {
|
|
194
|
+
if (lengthCode + extraLength !== 0x1_0e) {
|
|
179
195
|
throw new AbortedError();
|
|
180
196
|
}
|
|
181
197
|
}
|
|
182
198
|
lengthCode = LenBase[lengthCode] + extraLength;
|
|
183
199
|
}
|
|
184
|
-
return lengthCode +
|
|
200
|
+
return lengthCode + 0x1_00;
|
|
185
201
|
}
|
|
186
|
-
const lastByte = getLowestNBitsOf(this
|
|
187
|
-
if (this
|
|
188
|
-
this
|
|
202
|
+
const lastByte = getLowestNBitsOf(this.bitBuffer, 8);
|
|
203
|
+
if (this.compressionType === Compression.Binary) {
|
|
204
|
+
this.wasteBits(8);
|
|
189
205
|
return lastByte;
|
|
190
206
|
}
|
|
191
207
|
let value;
|
|
192
208
|
if (lastByte > 0) {
|
|
193
|
-
value = this
|
|
209
|
+
value = this.asciiTable2C34[lastByte];
|
|
194
210
|
if (value === 0xff) {
|
|
195
|
-
if (getLowestNBitsOf(this
|
|
196
|
-
this
|
|
197
|
-
value = this
|
|
211
|
+
if (getLowestNBitsOf(this.bitBuffer, 6)) {
|
|
212
|
+
this.wasteBits(4);
|
|
213
|
+
value = this.asciiTable2D34[getLowestNBitsOf(this.bitBuffer, 8)];
|
|
198
214
|
}
|
|
199
215
|
else {
|
|
200
|
-
this
|
|
201
|
-
value = this
|
|
216
|
+
this.wasteBits(6);
|
|
217
|
+
value = this.asciiTable2E34[getLowestNBitsOf(this.bitBuffer, 7)];
|
|
202
218
|
}
|
|
203
219
|
}
|
|
204
220
|
}
|
|
205
221
|
else {
|
|
206
|
-
this
|
|
207
|
-
value = this
|
|
222
|
+
this.wasteBits(8);
|
|
223
|
+
value = this.asciiTable2EB4[getLowestNBitsOf(this.bitBuffer, 8)];
|
|
208
224
|
}
|
|
209
|
-
this
|
|
225
|
+
this.wasteBits(this.chBitsAsc[value]);
|
|
210
226
|
return value;
|
|
211
227
|
}
|
|
212
228
|
/**
|
|
213
229
|
* @throws {@link AbortedError}
|
|
214
230
|
*/
|
|
215
|
-
|
|
216
|
-
const distPosCode = this
|
|
231
|
+
decodeDistance(repeatLength) {
|
|
232
|
+
const distPosCode = this.distPosCodes[getLowestNBitsOf(this.bitBuffer, 8)];
|
|
217
233
|
const distPosBits = DistBits[distPosCode];
|
|
218
|
-
this
|
|
234
|
+
this.wasteBits(distPosBits);
|
|
219
235
|
let distance;
|
|
220
236
|
let bitsToWaste;
|
|
221
237
|
if (repeatLength === 2) {
|
|
222
|
-
distance = (distPosCode << 2) | getLowestNBitsOf(this
|
|
238
|
+
distance = (distPosCode << 2) | getLowestNBitsOf(this.bitBuffer, 2);
|
|
223
239
|
bitsToWaste = 2;
|
|
224
240
|
}
|
|
225
241
|
else {
|
|
226
|
-
distance = (distPosCode << this
|
|
227
|
-
bitsToWaste = this
|
|
242
|
+
distance = (distPosCode << this.dictionarySize) | (this.bitBuffer & this.dictionarySizeMask);
|
|
243
|
+
bitsToWaste = this.dictionarySize;
|
|
228
244
|
}
|
|
229
|
-
this
|
|
245
|
+
this.wasteBits(bitsToWaste);
|
|
230
246
|
return distance + 1;
|
|
231
247
|
}
|
|
232
|
-
|
|
233
|
-
if (this
|
|
248
|
+
processChunkData() {
|
|
249
|
+
if (this.inputBuffer.isEmpty()) {
|
|
234
250
|
return;
|
|
235
251
|
}
|
|
236
|
-
if (this
|
|
237
|
-
const headerParsedSuccessfully = this
|
|
238
|
-
if (!headerParsedSuccessfully || this
|
|
252
|
+
if (this.compressionType === Compression.Unknown) {
|
|
253
|
+
const headerParsedSuccessfully = this.parseInitialData();
|
|
254
|
+
if (!headerParsedSuccessfully || this.inputBuffer.isEmpty()) {
|
|
239
255
|
return;
|
|
240
256
|
}
|
|
241
257
|
}
|
|
242
|
-
this
|
|
243
|
-
this
|
|
258
|
+
this.needMoreInput = false;
|
|
259
|
+
this.backup();
|
|
244
260
|
try {
|
|
245
|
-
let nextLiteral = this
|
|
261
|
+
let nextLiteral = this.decodeNextLiteral();
|
|
246
262
|
while (nextLiteral !== LITERAL_END_STREAM) {
|
|
247
|
-
if (nextLiteral >=
|
|
263
|
+
if (nextLiteral >= 0x1_00) {
|
|
248
264
|
const repeatLength = nextLiteral - 0xfe;
|
|
249
|
-
const minusDistance = this
|
|
250
|
-
const availableData = this
|
|
265
|
+
const minusDistance = this.decodeDistance(repeatLength);
|
|
266
|
+
const availableData = this.outputBuffer.read(this.outputBuffer.size() - minusDistance, repeatLength);
|
|
251
267
|
let addition;
|
|
252
268
|
if (repeatLength > minusDistance) {
|
|
253
269
|
const multipliedData = repeat(availableData, Math.ceil(repeatLength / availableData.length));
|
|
@@ -256,50 +272,50 @@ export class Explode {
|
|
|
256
272
|
else {
|
|
257
273
|
addition = availableData;
|
|
258
274
|
}
|
|
259
|
-
this
|
|
275
|
+
this.outputBuffer.append(addition);
|
|
260
276
|
}
|
|
261
277
|
else {
|
|
262
|
-
this
|
|
278
|
+
this.outputBuffer.appendByte(nextLiteral);
|
|
263
279
|
}
|
|
264
|
-
this
|
|
265
|
-
nextLiteral = this
|
|
280
|
+
this.backup();
|
|
281
|
+
nextLiteral = this.decodeNextLiteral();
|
|
266
282
|
}
|
|
267
283
|
}
|
|
268
|
-
catch
|
|
269
|
-
this
|
|
284
|
+
catch {
|
|
285
|
+
this.needMoreInput = true;
|
|
270
286
|
}
|
|
271
|
-
if (this
|
|
272
|
-
this
|
|
287
|
+
if (this.needMoreInput) {
|
|
288
|
+
this.restore();
|
|
273
289
|
}
|
|
274
290
|
}
|
|
275
|
-
|
|
276
|
-
if (this
|
|
291
|
+
parseInitialData() {
|
|
292
|
+
if (this.inputBuffer.size() < 4) {
|
|
277
293
|
return false;
|
|
278
294
|
}
|
|
279
|
-
const { compressionType, dictionarySize } = readHeader(this
|
|
280
|
-
this
|
|
281
|
-
this
|
|
282
|
-
this
|
|
283
|
-
this
|
|
284
|
-
this
|
|
285
|
-
if (this
|
|
286
|
-
this
|
|
295
|
+
const { compressionType, dictionarySize } = readHeader(this.inputBuffer.read(0, 2));
|
|
296
|
+
this.compressionType = compressionType;
|
|
297
|
+
this.dictionarySize = dictionarySize;
|
|
298
|
+
this.bitBuffer = this.inputBuffer.readByte(2);
|
|
299
|
+
this.inputBuffer.dropStart(3);
|
|
300
|
+
this.dictionarySizeMask = nBitsOfOnes(dictionarySize);
|
|
301
|
+
if (this.compressionType === Compression.Ascii) {
|
|
302
|
+
this.generateAsciiTables();
|
|
287
303
|
}
|
|
288
|
-
if (this
|
|
289
|
-
console.log(`explode: compression type: ${Compression[this
|
|
290
|
-
console.log(`explode: compression level: ${DictionarySize[this
|
|
304
|
+
if (this.verbose) {
|
|
305
|
+
console.log(`explode: compression type: ${Compression[this.compressionType]}`);
|
|
306
|
+
console.log(`explode: compression level: ${DictionarySize[this.dictionarySize]}`);
|
|
291
307
|
}
|
|
292
308
|
return true;
|
|
293
309
|
}
|
|
294
|
-
|
|
295
|
-
this
|
|
296
|
-
this
|
|
297
|
-
this
|
|
310
|
+
backup() {
|
|
311
|
+
this.backupData.extraBits = this.extraBits;
|
|
312
|
+
this.backupData.bitBuffer = this.bitBuffer;
|
|
313
|
+
this.inputBuffer.saveIndices();
|
|
298
314
|
}
|
|
299
|
-
|
|
300
|
-
this
|
|
301
|
-
this
|
|
302
|
-
this
|
|
315
|
+
restore() {
|
|
316
|
+
this.extraBits = this.backupData.extraBits;
|
|
317
|
+
this.bitBuffer = this.backupData.bitBuffer;
|
|
318
|
+
this.inputBuffer.restoreIndices();
|
|
303
319
|
}
|
|
304
320
|
}
|
|
305
321
|
//# sourceMappingURL=Explode.js.map
|
package/dist/Explode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Explode.js","sourceRoot":"","sources":["../src/Explode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,OAAO,EACP,OAAO,EACP,OAAO,EACP,kBAAkB,GACnB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE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C,UAAU,CAAC,SAAS,CAAA;QAC1C,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAA;IACnC,CAAC;CACF"}
|
package/dist/Implode.d.ts
CHANGED
|
@@ -1,10 +1,40 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
|
-
import { type Transform, type TransformCallback } from 'node:stream';
|
|
3
2
|
import { Compression, DictionarySize } from './constants.js';
|
|
3
|
+
import { type StreamHandler } from './stream.js';
|
|
4
4
|
import { type Config } from './types.js';
|
|
5
|
-
export declare
|
|
5
|
+
export declare function getSizeOfMatching(inputBytes: Buffer, a: number, b: number): number;
|
|
6
6
|
export declare class Implode {
|
|
7
|
-
|
|
7
|
+
private readonly verbose;
|
|
8
|
+
private isFirstChunk;
|
|
9
|
+
private readonly inputBuffer;
|
|
10
|
+
private readonly outputBuffer;
|
|
11
|
+
private readonly stats;
|
|
12
|
+
private readonly compressionType;
|
|
13
|
+
private readonly dictionarySize;
|
|
14
|
+
private dictionarySizeMask;
|
|
15
|
+
private streamEnded;
|
|
16
|
+
private readonly distCodes;
|
|
17
|
+
private readonly distBits;
|
|
18
|
+
private startIndex;
|
|
19
|
+
private handledFirstTwoBytes;
|
|
20
|
+
private outBits;
|
|
21
|
+
private nChBits;
|
|
22
|
+
private nChCodes;
|
|
8
23
|
constructor(compressionType: Compression, dictionarySize: DictionarySize, config: Config);
|
|
9
|
-
getHandler():
|
|
24
|
+
getHandler(): StreamHandler;
|
|
25
|
+
private onInputFinished;
|
|
26
|
+
private processChunkData;
|
|
27
|
+
/**
|
|
28
|
+
* @returns false - non flushable
|
|
29
|
+
* @returns true - flushable
|
|
30
|
+
* @returns null - flushable, but there might be a better repetition
|
|
31
|
+
*/
|
|
32
|
+
private isRepetitionFlushable;
|
|
33
|
+
/**
|
|
34
|
+
* repetitions are at least 2 bytes long,
|
|
35
|
+
* so the initial 2 bytes can be moved to the output as is
|
|
36
|
+
*/
|
|
37
|
+
private handleFirstTwoBytes;
|
|
38
|
+
private setup;
|
|
39
|
+
private outputBits;
|
|
10
40
|
}
|