Skip to content

Commit be5e008

Browse files
author
Yuta Imaya
committed
Merge branch 'release/0.1.3'
2 parents e5c08f9 + 4d05e4c commit be5e008

11 files changed

+154
-138
lines changed

‎bin/deflate.min.js

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bin/gzip.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bin/node-zlib.js

+38-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bin/zlib.min.js

+26-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bin/zlib_and_gzip.min.js

+43-43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
2-
"author": "imaya <imaya.devel@gmail.com>",
2+
"author": {
3+
"name": "Yuta Imaya"
4+
},
5+
"contributors": {
6+
"name": "Yuta Imaya",
7+
"email": "imaya.devel@gmail.com"
8+
},
39
"name": "zlibjs",
410
"description": "zlib and gzip implementation in JavaScript",
5-
"version": "0.1.2",
11+
"version": "0.1.3",
612
"main": "./bin/node-zlib.js",
713
"homepage": "https://github.com/imaya/zlib.js",
814
"repository": {

‎src/deflate.js

+4
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ if (ZLIB_DEFLATE_EXPORT) {
203203
'Zlib.Deflate.compress',
204204
Zlib.Deflate.compress
205205
);
206+
goog.exportSymbol(
207+
'Zlib.Deflate.prototype.compress',
208+
Zlib.Deflate.prototype.compress
209+
);
206210
goog.exportSymbol(
207211
'Zlib.Deflate.CompressionType',
208212
Zlib.Deflate.CompressionType

‎src/rawdeflate.js

+4-15
Original file line numberDiff line numberDiff line change
@@ -1189,33 +1189,22 @@ Zlib.RawDeflate.prototype.getCodesFromLengths_ = function(lengths) {
11891189
var codes = new (USE_TYPEDARRAY ? Uint16Array : Array)(lengths.length),
11901190
count = [],
11911191
startCode = [],
1192-
code = 0, i, l, j, m;
1192+
code = 0, i, il, j, m;
11931193

11941194
// Count the codes of each length.
1195-
for (i = 0, l = lengths.length; i < l; i++) {
1195+
for (i = 0, il = lengths.length; i < il; i++) {
11961196
count[lengths[i]] = (count[lengths[i]] | 0) + 1;
11971197
}
11981198

11991199
// Determine the starting code for each length block.
1200-
for (i = 1, l = Zlib.RawDeflate.MaxCodeLength; i <= l; i++) {
1200+
for (i = 1, il = Zlib.RawDeflate.MaxCodeLength; i <= il; i++) {
12011201
startCode[i] = code;
12021202
code += count[i] | 0;
1203-
1204-
// overcommited
1205-
if (code > (1 << i)) {
1206-
throw 'overcommitted';
1207-
}
1208-
12091203
code <<= 1;
12101204
}
12111205

1212-
// undercommitted
1213-
if (code < ((1 << Zlib.RawDeflate.MaxCodeLength) | 0)) {
1214-
throw 'undercommitted';
1215-
}
1216-
12171206
// Determine the code for each symbol. Mirrored, of course.
1218-
for (i = 0, l = lengths.length; i < l; i++) {
1207+
for (i = 0, il = lengths.length; i < il; i++) {
12191208
code = startCode[lengths[i]];
12201209
startCode[lengths[i]] += 1;
12211210
codes[i] = 0;

‎test/browser-plain-test.js

+6
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ buster.testCase(
126126
assert.equals(inflated.length, size, "inflated data size");
127127
assert(arrayEquals(inflated, plain));
128128
},
129+
"undercomitted": function() {
130+
var data = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23];
131+
var compressed = new Zlib.Deflate(data).compress();
132+
var decompressed = new Zlib.Inflate(compressed).decompress();
133+
assert(arrayEquals(data, Array.prototype.slice.call(decompressed)));
134+
},
129135
"uncompressed random data": function() {
130136
makeRandomData(this.testData);
131137
inflateTest('random', this.testData, Zlib.Deflate.CompressionType.NONE);

‎test/browser-test.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,12 @@ buster.testCase(
200200
assert.equals(inflated.buffer.byteLength, 123456, "inflated data buffer size");
201201
assert(arrayEquals(inflated, plain));
202202
},
203-
203+
"undercomitted": function() {
204+
var data = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23];
205+
var compressed = new Zlib.Deflate(data).compress();
206+
var decompressed = new Zlib.Inflate(compressed).decompress();
207+
assert(arrayEquals(data, Array.prototype.slice.call(decompressed)));
208+
},
204209
"uncompressed random data": function() {
205210
makeRandomData(this.testData);
206211
inflateTest('random', this.testData, Zlib.Deflate.CompressionType.NONE);

‎test/node-test.js

+6
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ buster.testCase(
111111
done();
112112
});
113113
},
114+
"undercomitted": function() {
115+
var data = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23];
116+
var compressed = zlib.deflateSync(data);
117+
var decompressed = zlib.inflateSync(compressed);
118+
assert(arrayEquals(data, Array.prototype.slice.call(decompressed)));
119+
},
114120
// js deflate, native inflate
115121
"random data": function(done) {
116122
makeRandomData(this.testData);

0 commit comments

Comments
 (0)