7z-iterator 0.1.6 → 0.1.7

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.
@@ -1,196 +0,0 @@
1
- diff --git a/node_modules/lzma-purejs/lib/LZMA/Decoder.js b/node_modules/lzma-purejs/lib/LZMA/Decoder.js
2
- index b82db68..3a124a1 100644
3
- --- a/node_modules/lzma-purejs/lib/LZMA/Decoder.js
4
- +++ b/node_modules/lzma-purejs/lib/LZMA/Decoder.js
5
- @@ -163,11 +163,26 @@ var Decoder = function(){
6
- this._dictionarySizeCheck = -1;
7
- this._posStateMask = 0;
8
-
9
- + // LZMA2 state preservation: these were local vars in code(), now instance props
10
- + this._state = 0;
11
- + this._rep0 = 0;
12
- + this._rep1 = 0;
13
- + this._rep2 = 0;
14
- + this._rep3 = 0;
15
- + this._prevByte = 0;
16
- + this._nowPos64 = 0; // Cumulative position for solid mode
17
- + this._solid = false; // When true, don't reset state in code()
18
- +
19
- for (i=0; i<Base.kNumLenToPosStates; i++) {
20
- this._posSlotDecoder[i] = new RangeCoder.BitTreeDecoder(Base.kNumPosSlotBits);
21
- }
22
- };
23
-
24
- +// LZMA2 support: Set solid mode to preserve state across chunks
25
- +Decoder.prototype.setSolid = function(solid) {
26
- + this._solid = solid;
27
- +};
28
- +
29
- Decoder.prototype.setDictionarySize = function(dictionarySize){
30
- if (dictionarySize < 0){
31
- return false;
32
- @@ -224,100 +239,120 @@ Decoder.prototype.init = function(){
33
- Decoder.prototype.code = function(inStream, outStream, outSize){
34
- // note that nowPos64 is actually only 53 bits long; that sets a limit
35
- // on the amount of data we can decode
36
- - var state, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0,
37
- - posState, decoder2, len, distance, posSlot, numDirectBits;
38
- + // LZMA2 patch: use instance properties for state vars instead of locals
39
- + // chunkPos tracks bytes in current chunk (for loop termination)
40
- + // cumPos tracks cumulative bytes across chunks (for posState, literal context, rep0 validation)
41
- + var chunkPos = 0, posState, decoder2, len, distance, posSlot, numDirectBits;
42
- + var cumPos;
43
-
44
- this._rangeDecoder.setStream(inStream);
45
- this._outWindow.setStream(outStream);
46
-
47
- - this.init();
48
- + // LZMA2 patch: only init when not in solid mode (state preservation)
49
- + if (!this._solid) {
50
- + this.init();
51
- + this._state = Base.stateInit();
52
- + this._rep0 = 0;
53
- + this._rep1 = 0;
54
- + this._rep2 = 0;
55
- + this._rep3 = 0;
56
- + this._prevByte = 0;
57
- + this._nowPos64 = 0;
58
- + } else {
59
- + // In solid mode, preserve dictionary (pass true), just init the range decoder
60
- + this._outWindow.init(true);
61
- + this._rangeDecoder.init();
62
- + }
63
- + cumPos = this._nowPos64;
64
-
65
- - state = Base.stateInit();
66
- - while(outSize < 0 || nowPos64 < outSize){
67
- - posState = nowPos64 & this._posStateMask;
68
- + while(outSize < 0 || chunkPos < outSize){
69
- + posState = cumPos & this._posStateMask;
70
-
71
- - if (this._rangeDecoder.decodeBit(this._isMatchDecoders, (state << Base.kNumPosStatesBitsMax) + posState) === 0){
72
- - decoder2 = this._literalDecoder.getDecoder(nowPos64, prevByte);
73
- + if (this._rangeDecoder.decodeBit(this._isMatchDecoders, (this._state << Base.kNumPosStatesBitsMax) + posState) === 0){
74
- + decoder2 = this._literalDecoder.getDecoder(cumPos, this._prevByte);
75
-
76
- - if (!Base.stateIsCharState(state)){
77
- - prevByte = decoder2.decodeWithMatchByte(this._rangeDecoder, this._outWindow.getByte(rep0) );
78
- + if (!Base.stateIsCharState(this._state)){
79
- + this._prevByte = decoder2.decodeWithMatchByte(this._rangeDecoder, this._outWindow.getByte(this._rep0) );
80
- }else{
81
- - prevByte = decoder2.decodeNormal(this._rangeDecoder);
82
- + this._prevByte = decoder2.decodeNormal(this._rangeDecoder);
83
- }
84
- - this._outWindow.putByte(prevByte);
85
- - state = Base.stateUpdateChar(state);
86
- - nowPos64++;
87
- + this._outWindow.putByte(this._prevByte);
88
- + this._state = Base.stateUpdateChar(this._state);
89
- + chunkPos++; cumPos++;
90
-
91
- }else{
92
-
93
- - if (this._rangeDecoder.decodeBit(this._isRepDecoders, state) === 1){
94
- + if (this._rangeDecoder.decodeBit(this._isRepDecoders, this._state) === 1){
95
- len = 0;
96
- - if (this._rangeDecoder.decodeBit(this._isRepG0Decoders, state) === 0){
97
- - if (this._rangeDecoder.decodeBit(this._isRep0LongDecoders, (state << Base.kNumPosStatesBitsMax) + posState) === 0){
98
- - state = Base.stateUpdateShortRep(state);
99
- + if (this._rangeDecoder.decodeBit(this._isRepG0Decoders, this._state) === 0){
100
- + if (this._rangeDecoder.decodeBit(this._isRep0LongDecoders, (this._state << Base.kNumPosStatesBitsMax) + posState) === 0){
101
- + this._state = Base.stateUpdateShortRep(this._state);
102
- len = 1;
103
- }
104
- }else{
105
- - if (this._rangeDecoder.decodeBit(this._isRepG1Decoders, state) === 0){
106
- - distance = rep1;
107
- + if (this._rangeDecoder.decodeBit(this._isRepG1Decoders, this._state) === 0){
108
- + distance = this._rep1;
109
- }else{
110
- - if (this._rangeDecoder.decodeBit(this._isRepG2Decoders, state) === 0){
111
- - distance = rep2;
112
- + if (this._rangeDecoder.decodeBit(this._isRepG2Decoders, this._state) === 0){
113
- + distance = this._rep2;
114
- }else{
115
- - distance = rep3;
116
- - rep3 = rep2;
117
- + distance = this._rep3;
118
- + this._rep3 = this._rep2;
119
- }
120
- - rep2 = rep1;
121
- + this._rep2 = this._rep1;
122
- }
123
- - rep1 = rep0;
124
- - rep0 = distance;
125
- + this._rep1 = this._rep0;
126
- + this._rep0 = distance;
127
- }
128
- if (len === 0){
129
- len = Base.kMatchMinLen + this._repLenDecoder.decode(this._rangeDecoder, posState);
130
- - state = Base.stateUpdateRep(state);
131
- + this._state = Base.stateUpdateRep(this._state);
132
- }
133
- }else{
134
- - rep3 = rep2;
135
- - rep2 = rep1;
136
- - rep1 = rep0;
137
- + this._rep3 = this._rep2;
138
- + this._rep2 = this._rep1;
139
- + this._rep1 = this._rep0;
140
-
141
- len = Base.kMatchMinLen + this._lenDecoder.decode(this._rangeDecoder, posState);
142
- - state = Base.stateUpdateMatch(state);
143
- + this._state = Base.stateUpdateMatch(this._state);
144
-
145
- posSlot = this._posSlotDecoder[Base.getLenToPosState(len)].decode(this._rangeDecoder);
146
- if (posSlot >= Base.kStartPosModelIndex){
147
-
148
- numDirectBits = (posSlot >> 1) - 1;
149
- - rep0 = (2 | (posSlot & 1) ) << numDirectBits;
150
- + this._rep0 = (2 | (posSlot & 1) ) << numDirectBits;
151
-
152
- if (posSlot < Base.kEndPosModelIndex){
153
- - rep0 += RangeCoder.BitTreeDecoder.reverseDecode(this._posDecoders,
154
- - rep0 - posSlot - 1, this._rangeDecoder, numDirectBits);
155
- + this._rep0 += RangeCoder.BitTreeDecoder.reverseDecode(this._posDecoders,
156
- + this._rep0 - posSlot - 1, this._rangeDecoder, numDirectBits);
157
- }else{
158
- - rep0 += this._rangeDecoder.decodeDirectBits(numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits;
159
- - rep0 += this._posAlignDecoder.reverseDecode(this._rangeDecoder);
160
- - if (rep0 < 0){
161
- - if (rep0 === -1){
162
- + this._rep0 += this._rangeDecoder.decodeDirectBits(numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits;
163
- + this._rep0 += this._posAlignDecoder.reverseDecode(this._rangeDecoder);
164
- + if (this._rep0 < 0){
165
- + if (this._rep0 === -1){
166
- break;
167
- }
168
- return false;
169
- }
170
- }
171
- }else{
172
- - rep0 = posSlot;
173
- + this._rep0 = posSlot;
174
- }
175
- }
176
-
177
- - if (rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck){
178
- + if (this._rep0 >= cumPos || this._rep0 >= this._dictionarySizeCheck){
179
- return false;
180
- }
181
-
182
- - this._outWindow.copyBlock(rep0, len);
183
- - nowPos64 += len;
184
- - prevByte = this._outWindow.getByte(0);
185
- + this._outWindow.copyBlock(this._rep0, len);
186
- + chunkPos += len; cumPos += len;
187
- + this._prevByte = this._outWindow.getByte(0);
188
- }
189
- }
190
-
191
- + // LZMA2: save cumulative position for next solid chunk
192
- + this._nowPos64 = cumPos;
193
- +
194
- this._outWindow.flush();
195
- this._outWindow.releaseStream();
196
- this._rangeDecoder.releaseStream();