imaya / zlib.js Goto Github PK
View Code? Open in Web Editor NEWcompact zlib, deflate, inflate, zip library in JavaScript
License: Other
compact zlib, deflate, inflate, zip library in JavaScript
License: Other
<html>
<script src="zlib_and_gzip.min.js" type="text/javascript"></script>
<script type="text/javascript">
var post_data = "examid=5249536&exam_id=5249536&BeginTime=1403861352&EndTime=1403861358.231&daan%5B60495%5D=D&daan%5B60496%5D=C&daan%5B60497%5D=C&daan%5B60498%5D=C&daan%5B60500%5D=A&daan%5B60501%5D=C&daan%5B60503%5D=D&daan%5B60504%5D=D&daan%5B60506%5D=D&daan%5B60507%5D=B&daan%5B60508%5D=D&daan%5B60511%5D=D&daan%5B60514%5D=D&daan%5B60517%5D=A&daan%5B60518%5D=C&daan%5B60513%5D=C&daan%5B60510%5D=C&daan%5B60505%5D=C&daan%5B60502%5D=C&daan%5B60499%5D=&daan%5B60509%5D=&daan%5B60512%5D=&daan%5B60516%5D=&daan%5B60519%5D=&daan%5B60520%5D=&daan%5B60524%5D=&daan%5B60528%5D=&daan%5B60531%5D=&daan%5B60535%5D=&daan%5B60539%5D=&daan%5B60547%5D=&daan%5B60559%5D=&daan%5B60568%5D=&daan%5B60572%5D=&daan%5B60577%5D=&daan%5B60580%5D=&daan%5B60585%5D=&daan%5B60588%5D=&daan%5B60593%5D=&daan%5B60600%5D=&daan%5B60521%5D=&daan%5B60525%5D=&daan%5B60527%5D=&daan%5B60530%5D=&daan%5B60532%5D=&daan%5B60534%5D=&daan%5B60538%5D=&daan%5B60540%5D=&daan%5B60543%5D=&daan%5B60555%5D=&daan%5B60560%5D=&daan%5B60569%5D=&daan%5B60571%5D=&daan%5B60573%5D=&daan%5B60576%5D=&daan%5B60579%5D=&daan%5B60581%5D=&daan%5B60584%5D=&daan%5B60587%5D=&daan%5B60591%5D=&daan%5B60480%5D=&daan%5B60484%5D=&daan%5B60485%5D=&daan%5B60481%5D=&daan%5B60486%5D=&daan%5B60482%5D=&daan%5B60487%5D=&daan%5B60483%5D=&daan%5B60488%5D=&daan%5B60489%5D=&daan%5B60490%5D=&daan%5B60491%5D=&daan%5B60492%5D=&daan%5B60493%5D=&daan%5B60494%5D=&daan%5B60523%5D=&daan%5B60529%5D=&daan%5B60533%5D=&daan%5B60537%5D=&daan%5B60542%5D=&daan%5B60562%5D=&daan%5B60575%5D=&daan%5B60582%5D=&daan%5B60589%5D=&daan%5B60603%5D=&daan%5B60605%5D=&daan%5B60607%5D=&daan%5B60606%5D=&daan%5B60604%5D=&daan%5B60602%5D=&daan%5B60601%5D=&daan%5B60594%5D=&daan%5B60590%5D=&daan%5B60586%5D=&daan%5B60583%5D=&daan%5B60578%5D=&daan%5B60574%5D=&daan%5B60570%5D=&daan%5B60561%5D=&daan%5B60551%5D=&daan%5B60536%5D=&daan%5B60541%5D=&daan%5B60526%5D=&daan%5B60515%5D=&daan%5B60522%5D=&daan%5B60613%5D=&daan%5B60614%5D=&daan%5B60616%5D=&daan%5B60617%5D=&daan%5B60619%5D=&daan%5B60620%5D=&daan%5B60622%5D=&daan%5B60621%5D=&daan%5B60618%5D=&daan%5B60615%5D=&daan%5B60563%5D=&daan%5B60564%5D=&daan%5B60565%5D=&daan%5B60566%5D=&daan%5B60567%5D=&daan%5B60595%5D=&daan%5B60596%5D=&daan%5B60597%5D=&daan%5B60598%5D=&daan%5B60599%5D=&daan%5B60608%5D=&daan%5B60609%5D=&daan%5B60610%5D=&daan%5B60611%5D=&daan%5B60612%5D=&daan%5B60627%5D=&daan%5B60628%5D=&daan%5B60629%5D=&daan%5B60630%5D=&daan%5B60631%5D=";
function compress_with_gzip(string){
zlib_option = {CompressionMethod:3,lazy:9};
flags = {
fname:true,
comment:true,
fhcrc:true
};
option = {filename:'answer',
comment:'by Luo Zijun.',
flags:flags
};
var gzip = new Zlib.Gzip(string,option);
return gzip.compress();
}
var enc = compress_with_gzip(post_data);
var compressed_data = "";
for (var i=0; i<enc.byteLength; i++){
compressed_data += enc[i];
if (i != enc.byteLength -1) compressed_data += ',';
}
console.log(compressed_data);
// OUTPUT:
/**
31,139,8,10,21,121,173,83,0,255,97,110,115,119,101,114,0,98,121,32,76,117,111,32,90,105,106,117,110,46,0,93,106,101,150,65,22,195,32,8,5,163,34,226,253,47,92,196,69,113,232,166,205,60,5,254,199,96,63,255,248,103,118,217,115,168,255,122,159,207,211,97,223,215,228,27,166,109,204,126,22,188,200,190,62,218,217,235,27,63,253,124,171,127,159,101,127,162,135,60,100,21,98,32,254,116,200,67,90,89,51,144,107,126,82,72,100,127,72,100,127,72,100,207,164,69,174,135,148,200,45,226,60,164,168,104,81,225,67,66,215,147,61,28,123,72,47,254,236,67,242,18,130,22,123,50,8,225,25,112,139,119,19,32,52,102,16,130,18,240,86,3,68,241,25,48,139,132,77,9,76,174,80,102,89,212,178,24,195,88,186,177,14,99,208,29,173,248,3,63,224,84,75,113,157,65,59,235,24,140,49,88,250,160,167,131,133,9,99,8,42,157,147,117,120,237,0,244,116,81,203,98,208,197,243,177,24,195,24,195,168,197,232,199,198,22,97,163,132,49,132,157,19,166,21,67,165,98,48,89,88,135,24,212,10,143,131,24,212,202,102,165,69,203,102,90,30,41,217,229,5,162,235,157,38,15,174,24,244,84,120,164,180,188,30,229,240,115,5,213,234,29,157,25,32,134,222,49,153,1,218,224,122,9,144,86,239,200,206,231,131,6,209,245,201,102,79,182,114,174,50,46,24,116,149,215,131,117,248,24,134,235,76,43,101,24,148,121,90,166,3,229,223,233,159,1,29,227,144,214,123,169,100,192,206,113,106,107,73,203,57,166,247,94,202,160,12,20,154,172,244,84,203,22,250,161,101,24,112,203,253,39,144,65,217,82,166,118,57,184,212,194,155,208,123,77,80,252,40,142,209,117,94,124,202,247,214,13,35,136,44,63,26,42,69,165,84,9,0,0
**/
</script>
</html>
data = "31,139,8,10,21,121,173,83,0,255,97,110,115,119,101,114,0,98,121,32,76,117,111,32,90,105,106,117,110,46,0,93,106,101,150,65,22,195,32,8,5,163,34,226,253,47,92,196,69,113,232,166,205,60,5,254,199,96,63,255,248,103,118,217,115,168,255,122,159,207,211,97,223,215,228,27,166,109,204,126,22,188,200,190,62,218,217,235,27,63,253,124,171,127,159,101,127,162,135,60,100,21,98,32,254,116,200,67,90,89,51,144,107,126,82,72,100,127,72,100,127,72,100,207,164,69,174,135,148,200,45,226,60,164,168,104,81,225,67,66,215,147,61,28,123,72,47,254,236,67,242,18,130,22,123,50,8,225,25,112,139,119,19,32,52,102,16,130,18,240,86,3,68,241,25,48,139,132,77,9,76,174,80,102,89,212,178,24,195,88,186,177,14,99,208,29,173,248,3,63,224,84,75,113,157,65,59,235,24,140,49,88,250,160,167,131,133,9,99,8,42,157,147,117,120,237,0,244,116,81,203,98,208,197,243,177,24,195,24,195,168,197,232,199,198,22,97,163,132,49,132,157,19,166,21,67,165,98,48,89,88,135,24,212,10,143,131,24,212,202,102,165,69,203,102,90,30,41,217,229,5,162,235,157,38,15,174,24,244,84,120,164,180,188,30,229,240,115,5,213,234,29,157,25,32,134,222,49,153,1,218,224,122,9,144,86,239,200,206,231,131,6,209,245,201,102,79,182,114,174,50,46,24,116,149,215,131,117,248,24,134,235,76,43,101,24,148,121,90,166,3,229,223,233,159,1,29,227,144,214,123,169,100,192,206,113,106,107,73,203,57,166,247,94,202,160,12,20,154,172,244,84,203,22,250,161,101,24,112,203,253,39,144,65,217,82,166,118,57,184,212,194,155,208,123,77,80,252,40,142,209,117,94,124,202,247,214,13,35,136,44,63,26,42,69,165,84,9,0,0"
z_array = data.split(',')
compressed_data = '';
for x in z_array:
compressed_data += chr(int( x) )
open('test.gz','wb').write(compressed_data)
luozijun@luozijun-LIFEBOOK-LH532:/var/www/new/trunk$ file test.gz
test.gz: gzip compressed data, has CRC, was "answer", last modified: Fri Jun 27 22:00:53 2014
luozijun@luozijun-LIFEBOOK-LH532:/var/www/new/trunk$ gzip -d test.gz
gzip: test.gz: header checksum 0x7962 != computed checksum 0xd0f0
luozijun@luozijun-LIFEBOOK-LH532:/var/www/new/trunk$ gzip -t test.gz
gzip: test.gz: header checksum 0x7962 != computed checksum 0xd0f0
luozijun@luozijun-LIFEBOOK-LH532:/var/www/new/trunk$
Checksum Problems
following is my test code. just use zlib.js compress some string and use decode it. but it alway failed
var zlibjs = require('zlibjs');
var result = zlibjs.gzipSync('hello world');
console.log('raw:', zlibjs.gunzipSync(result).toString());
error message
[jerry@nelo76 example]$ node testzlib.js
/home/jerry/repository/kafka-node/node_modules/zlibjs/bin/node-zlib.js:1
s ] The MIT License */(function() {'use strict';function q(b){throw b;}var t=v
^
Error: invalid CRC-32 checksum: 0x9d6cdf7e / 0x6b87b1ec
at Error (<anonymous>)
at nb.i (/home/jerry/repository/kafka-node/node_modules/zlibjs/bin/node-zlib.js:47:440)
at Object.Bb [as gunzipSync] (/home/jerry/repository/kafka-node/node_modules/zlibjs/bin/node-zlib.js:52:424)
at Object.<anonymous> (/home/jerry/repository/kafka-node/example/testzlib.js:9:28)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
I just posted a jsperf comparing zlib.js with two other js zlibs. The performance in chrome & ff is markedly different.
Any idea what that's about?
It wouldn't be surprising if the tests were off somehow, though I tried to make them equivalent.
when i inflate the data.throw this error "input buffer is broken".
binary data:[132,81,219,106,132,48,16,253,151,121,14,197,24,111,248,216,244,11,90,223,138,148,96,82,42,68,83,84,22,22,241,223,119,178,94,88,67,188,128,195,220,206,57,227,113,4,105,32,7,222,200,183,15,37,244,151,210,191,92,116,242,211,152,6,123,63,239,157,4,2,82,12,2,242,17,234,118,80,221,77,232,162,110,20,228,1,129,214,12,117,133,233,247,8,21,162,184,22,125,191,85,152,80,124,8,101,54,68,54,80,26,18,26,210,176,156,200,241,78,134,85,86,78,37,121,110,20,247,127,20,96,43,192,35,97,247,83,164,77,240,141,49,143,118,236,236,98,188,27,161,58,115,148,227,19,229,215,195,29,88,114,6,155,77,32,27,129,99,199,54,94,156,240,122,229,181,41,189,86,245,210,237,155,62,230,204,150,127,162,149,252,240,43,150,255,23,209,96,189,206,117,126,182,119,122,4,0,0,255,255]
only this data have errer. can i help me resolve this problem?
I have an application which updates the InflateStream with very small chunks (about 1-200 long Uint8Array). However the inflatestream copies the data too much times, calling the update on inflate has very bad performance. My workaround now is waiting for larger chunks of data (1MB) and passing it to InflateStream, however this requires one avoidable copy.
Do you have any idea how to improve this? Probably some kind of configurable output buffer size of InflateStream would solve my issue, however I was unable to figure it out how to achieve this in InflateStream.
Here is a reproduction code written with node.js:
var zlibjs = require('zlibjs');
function do_test(src) {
var srcStr = JSON.stringify(src);
try{
var compressed = zlibjs.deflateSync(src);
var inflated = zlibjs.inflateSync(compressed);
var inflatedStr = JSON.stringify(inflated);
if (srcStr!=inflatedStr) {
console.log("not equal: " + srcStr + " to " + inflatedStr);
}
}catch(ex){
console.log(ex.message, "src:"+srcStr);
}
}
// success
do_test([0,1,2,3,4,5,6,7]);
// not equal
do_test([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,228,0,0,0,0,0,0,97,0,0,215,0,0,0,0,0,97,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,174,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44,166,0,0,0,0,101,0,0,0,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,139,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,186,0,111,0,0,218,0,0,0,0,0,0,0,0,0,0,0,111]);
do_test([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,231,0,0,0,0,0,0,0,0,22,8,0,0,0,0,0,0,0,0,0,0,0,0,0,99,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,243,0,194,0,0,0,0,8,0,0,0,0,0,0,9,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,86,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,45,0,0,0,0,0,0,0,0,0,0,0,0,0,81,0,0,0,0,0,0,0,0,191,0,0,108,0,0,0,0,169,0,0,60,0,0,0,0,165,0,0,0,0,0,0,0,0,92,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,168,0,0,0,0,0,0,0,0,0,0,0,0,0,152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);
// take a long time and finally throw an exception
do_test([125,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,150,0,237,0,41,0,0,0,0,0,0,0,0,54,0,90,0,0,0,0,0,0,0,0,4,0,72,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,140,103,0,145,170,0,0,0,0,0,0,0,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,137,33,0,0,0,0,0,0,0,163,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,230,0,0,0,0,0,0,0,0,0,0,0,122,0,0,0,0,0,0,0,196,51,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,46,0,49,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,111,0,0,0,0,0,56,0,0,0,0,0,0,0,0,0,133,0,0,0,0,6,0,0,0,0,215,21,0,0,0,0]);
// random test
/*
for(var i=0;i<10000;++i) {
var bf = new Buffer(Math.floor(Math.random()*300));
for(var j=0;j<bf.length;++j) bf[j] = (Math.random()<0.9) ? 0 : Math.floor(Math.random()*256);
do_test(bf);
}
*/
inflate_stream.min.js appears to be identical to inflate.min.js, according to build.xml it is compiled from the same source file.
It also doesn't appear to be included in the zlib bundle as your english readme suggests.
Branch | Build failing 🚨 |
---|---|
Dependency | grunt |
Current Version | 1.0.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
grunt is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 27 commits.
ccc3163
v1.0.2
e7795dc
Remove iojs from test matrix (#1622)
a6a133b
Remove deprecation warning for coffeescript (#1621) r=@vladikoff
06b377e
https links to webchat.freenode.net and gruntjs.com (#1610)
7c5242f
Use node executable for local grunt bin for Windows support
f6cbb63
Oh right, Windows isnt bash
a9a20da
Try and debug why appveyor is failing on npm
48bba6c
Move to the test script to avoid npm was unexpected at this time.
6b97ac0
Try to fix appveyor script
19003ba
For appveyor, check node version to decide whether to install npm@3
3fcf921
Install npm@3 if npm version is npm 1 or 2
77fc157
Use the local version of grunt to run tests
400601a
Updating devDependencies
6592ad1
Update travis/appveyor to node versions we support
b63aeec
Dont manually install npm, use the version each node version corresponds with
There are 27 commits in total.
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Hi!
I am investigating an idea to make use of the browsers built in gzip decompression facility by using the Blob API. It appears that the only obstacle is the ability to set Content-Encoding for the blob.
I hereby want to inform if anyone knows of a solution to use a javascript Blob to uncompress gzip data.
The code that I use to test via the browser console is the following. It will change the background of a page to green on success.
/* create blob */
var createBlobUrl = function(fileData,mimeType) {
var blob;
// Create blob
try {
blob = new Blob([fileData], {type: mimeType});
} catch (e) { // Backwards-compatibility
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
blob = new BlobBuilder();
blob.append(fileData);
blob = blob.getBlob(mimeType);
}
return URL.createObjectURL(blob);
};
/* CSS: body, * { background:green; } */
var zip = window.atob('H4sIAAAAAAAA/0vKT6nUUdBSqFZISkzOTi/KL81LsUovSk3Ns1aoBQCLj6wTHQAAAA==');
function str2bytes (str) {
var bytes = new Uint8Array(str.length);
for (var i=0; i<str.length; i++) {
bytes[i] = str.charCodeAt(i);
}
return bytes;
}
var bloburl = createBlobUrl(str2bytes(zip),'text/css');
var link = document.createElement('link');
link.setAttribute('rel','stylesheet');
link.setAttribute('type','text/css');
link.setAttribute('href',bloburl);
document.head.appendChild(link);
Branch | Build failing 🚨 |
---|---|
Dependency | sinon |
Current Version | 3.2.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As sinon is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 15 commits.
dbef9aa
Update docs/changelog.md and set new release id in docs/_config.yml
97b0535
Add release documentation for v3.2.1
359e78b
3.2.1
590ae7d
Update Changelog.txt and AUTHORS for new release
d9cae73
Merge pull request #1532 from EyalAr/master
4f40409
fix fakeServerWithClock.create function mock to return a unique value
4310343
Merge pull request #1533 from noisecapella/gs/fix_undefined
f87b512
resolvesThis should override previous throws
a85a355
fix tests that stub nise.fakeServer.create & fakeServerWithClock.create
5c3fb95
preserve context of functions from nise: fakeServer, fakeServerWithClock
b509f4e
add tests for issue #1531
28bcedc
Merge pull request #1530 from noisecapella/gs/regression_onfirstcall
7b53434
Fix regression for issue #1526 regarding onFirstCall().throws()
350717d
Remove superfluous
2a04615
Fix docs regression introduced by #1523
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
The gzip have a magic data. But How to known the data is deflated?
It would be awesome if all the foreign comments, I assume japanese, would be rewritten in english.
I used this library because I needed zlib inflate in the browser and it worked immediately.
A further suggestion, could you provide some info on how you are building all the files in bin? A makefile system for doing that would be awesome.
It would be great to be able to have a NuGet package for zlib. More and more people are using it for installing and updating libraries like this.
Would you be able to package this up into a NuGet package?
I ran across this while debugging something:
var Zlib = require('./bin/node-zlib');
var data = new Buffer([
0x08, 0x1D, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x61,
0x2f, 0x62, 0x6c, 0x61, 0x68, 0x2e, 0x6a, 0x73,
0x55, 0x58, 0x0c, 0x00, 0x14, 0x2c, 0xdb, 0x55,
0xa9, 0x98, 0x85, 0x55, 0xf5, 0x01, 0x14, 0x00,
0x2b, 0x4b, 0x2c, 0x52, 0x28, 0x4e, 0x2d, 0x2a,
0x4b, 0x2d, 0x52, 0xb0, 0x55, 0xc8, 0x28, 0x29,
0x29, 0xd0, 0x4b,
]);
console.log(Zlib.inflateSync(data));
It looks like a hang in decodeHuffmanAdaptive
. This bug is especially unfortunate because it's been ported to other implementations that are based on this library (https://github.com/brendan-duncan/archive for example).
my code like this:
var encodeString = "eJzVzM0KQEAYRuHJ38LCv7CVQbn/+3PUp96NGll560kzc+LcvzeIkE0iZAVKVHaeH7rWvpuIESFBikzau1+xW69rrLnePBa796LGgREdeuvzl/2X/5+q7QaO";
var originalArray = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,23,23,23,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,14,15,16,0,34,0,0,0,0,0,19,0,39,39,39,3,2,4,5,6,0,19,19,0,38,40,39,0,0,0,18,19,40,37,36,0,37,37,37,17,43,24,20,21,40,10,36,0,37,37,37,17,43,24,20,21,40,37,36,0,37,37,37,17,43,24,20,21,40,10,36,0];
var decodedData = decodeB64(encodeString );
var inflator = new Zlib.Inflate(decodedData);
var inflated = inflator.decompress();
the result is:
inflated != originalArray ;
note:
encodeString and originalArray from TilemapEditor.
Is some parameters lose?
Thanks!
Currently, only synchronous compression / decompression is supported. It would be great if a callback could be passed (or better, a promise returned) to provide a way to compress / decompress asynchronously.
https://npmjs.org/package/zlibjs has not been taken, so you could publish as-is.
This would help other modules such as jszip ( https://github.com/Stuk/jszip/blob/master/package.json#L53 )
In gunzip.js there is a conditional around line 200 where inflen is set. If the conditional evaluates false, inflen is undefined in the call to RawInflate, and an error is thrown. This can happen, for example, on blocks with zero length. Here is an example:
https://github.com/samtools/tabix/blob/master/example.gtf.gz.tbi?raw=true
This file has two blocks. The second one is zero length.
Is there a fallback for files larger than 2.1GB?
I am exploring the gzip library, I am getting 'Uncaught Error: invalid CRC-32 checksum' error with my sample code. Please see the code and error below.
Please help me to resolve this issue.
var zipper = new Zlib.Gzip("Try to compress this string....");
var compressed = zipper.compress();
var uncompressed = new Zlib.Gunzip(compressed);
var original = uncompressed.decompress();
console.log(original);
Uncaught Error: invalid CRC-32 checksum: 0x43eb5 / 0x6909acb0
I was looking around your code, and noticed a mistake in the type annotation for some variables in the dynamicHuffman
method.
Starting here: https://github.com/imaya/zlib.js/blob/master/src/rawdeflate.js#L410
litLenCodes
and distCodes
are Uint16Array
(or an array of numbers).
litLenLengths
and distLengths
are Uint8Array
(or an array of numbers)
Currently, they are annotated as numbers, which is incorrect.
Thanks for making this (very well annotated) library!
Please disregard issue, fixed myself :)
I just tried loading zlib.min.js, but the browser errors on load with
Uncaught TypeError: Cannot use 'in' operator to search for 'Zlib' in undefined
I'm guessing this is a google closure problem. Is there some support library needed?
There is no choice between Array and Uint8Array based on value of USE_TYPEDARRAY in functions makeDynamicHuffmanBlock, makeFixedHuffmanBlock (source file rawdeflate.js): Uint8Array is created unconditionaly.
Tried to help start with
Branch | Build failing 🚨 |
---|---|
Dependency | sinon |
Current Version | 2.3.8 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As sinon is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 11 commits.
20eb865
Update docs/changelog.md and set new release id in docs/_config.yml
e333e75
Add release documentation for v2.4.0
fde7911
2.4.0
9afdcfc
Update Changelog.txt and AUTHORS for new release
57bb8b3
Merge pull request #1489 from Rowno/named-anonymous-mocks
c9a35ef
Update fake-xhr-and-server.md
837ec0c
Allow anonymous mock functions to be named
259a330
Merge pull request #1481 from fatso83/fix-safari-breaking
e742268
Merge pull request #1488 from VynceMontgomery/patch-1
a6a2b8c
Clarify behavior of useFakeTimers
24d15f2
Avoid running test for #1456 on Safari
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Hi! I would like to build simple concat versions. Right now I can only build .min
but for debugging it would be nice to have unminified builds.
something like: ant concat
Thanks!
My code is something like
var plain = "Example string"; var deflate = new Zlib.Deflate(plain); var compressed = deflate.compress();
Here, compressed
is a Uint8 Array.
var inflate = new Zlib.Inflate(compressed); var output = inflate.decompress();
I would want the output to be "Example string", but it is just another Uint8 Array. Why is it nor working?
I tried Gzip and Raw too.
Error: THREE.FBXLoader: External library Inflate.min.js required, obtain or import from https://github.com/imaya/zlib.js — FBXLoader.js:4350
I am trying to load a fbx file with two animations move and rotate. However, getting the above error. Issue is persistent in only this file. The animation was made in blender using a primitive monkey.
Below is the .blend and .fbx file for reference.
https://drive.google.com/file/d/0B6Qltc_0EwVGd0JrazJKZmQ0M0U/view?usp=sharing
https://drive.google.com/file/d/0B6Qltc_0EwVGa0dZVnlwenQ1Yk0/view?usp=sharing
Heap の実装バグにより、ハフマン符号による圧縮効率が良くないことになっている。
Recently i find Zlib.Inflate doen't work when operate large data.
var array=Uint8Array(671048); //array length is 671048
var content = new Zlib.Deflate(content); //now content length is 179038
new Zlib.Inflate(content); //it does not work, ever i use some option like bufferSize..
another situation
var array=Uint8Array(591122); //array length is 591122
var content = new Zlib.Deflate(content); //now content length is 147314
new Zlib.Inflate(content); //it works
i am appreciate for any help.
hi man.
I met a question when i used Gzip to decompress String.When I decompress a utf-8 Chinese String.it will be wrong.
Because i use ajax to exchange data.And the xhr.responseText is gziped by server.
so i need to decompress the data on browser.
can you give me some advice?
thx : )
Hi,
with the current version of Chrome I suddenly get the following error when loading zlib.min.js
:
GET http://myserver/zlib.min.js.map 401 (Unauthorized)
What could be the reason for that? With earlier versions I had no problems. FF works also.
Thanks for any help!
Jochen
Hi, does Zlib.js run in a web worker? I use the inflate_stream.js in my project and want to move the code to a web worker, but it failed to load the script.
Does anyone have had success to run Zlib.js in a worker?
As reported on Stuk/jszip#97, deflate/inflate fails for some files.
With the file export17.idbql (in this zip file), the following code fails :
var zlibjs = require("zlibjs");
var fs = require("fs");
var assert = require("assert");
var original = fs.readFileSync("export17.idbql");
var compressed = zlibjs.deflateSync(original);
var decompressed = zlibjs.inflateSync(compressed);
assert.equal(original.length, decompressed.length);
console.log("OK");
I get the error AssertionError: 1000049 == 390085
: the decompressed content is not the same as the original.
Hi,
I know this isn't really a question specifically for this lib, but can someone help me use this together with typescript? I tried specifying (in my tsconfig.json)
"paths": { "zlib_and_gzip": [ "node_modules/zlibjs/bin/zlib_and_gzip.min" ]
But I'm getting an error saying:
error TS2306: File 'node_modules/zlibjs/bin/zlib_and_gzip.min.js' is not a module.
Which isn't really a surprise... but is there a way to use it anyway?
If not, how would I got about packaging this using modules or can you suggest where to post this question?
Regards, Martin
I want to compress the pcm data produce by WebAudio API, it is Int16Array.
Can I use zlib.js?
I've looked through the source code, and sadly I've not found anyway to specify the specific compression level. E.g. level 0-9. I don't know if it's already in the code, and I've just missed it(looking through it) but if it's already in there you can safely close this issue, but I would at the very least like to see it in there. I was shopping around for a good zlib/zip compressor for the in browser stuff. I saw this one, it looks really interesting, but it's not able to do that one thing. I was going to benchmark the various implementations(after closure compiling) and then look at the best api ones and then pit them against eachother for whoever was faster won.
Babel appears to be looking at .babelrc in each npm package.
Please add .babelrc to .npmignore or use files section in package.json.
<script src="gzip.min.js" type="text/javascript"></script>
<script src="gunzip.min.js" type="text/javascript"></script>
<script type="text/javascript">
// Gzip
var plain = "hello";
console.log('Input String: ' + plain);
// plain = Array.<number> or Uint8Array
var gzip = new Zlib.Gzip(plain);
var compressed = gzip.compress();
console.log(compressed);
// compressed = Array.<number> or Uint8Array
var gunzip = new Zlib.Gunzip(compressed);
var plain = gunzip.decompress();
console.log(plain);
</script>
Note: Run This JavaScript In Google Chrome Brower(Ver:35.0.1916.153).
Input String: hello zlib.html:20
[31, 139, 8, 0, 37, 38, 173, 83, 0, 255, 13, 192, 129, 0, 0, 0, 0, 0, 144, 255, 107, 4, 29, 247, 34, 198, 5, 0, 0, 0] zlib.html:24
Uncaught Error: invalid CRC-32 checksum: 0xff41d912 / 0xc622f71d gunzip.min.js:25
#9 Does CRC-32 lib have problems?
Why the size of this lib is so big?
The version 0.1.7 is about 34M, the latest 0.2.0 version is still about 7M.
i installed the lasted version of buster,and i found the unit test could not run correctly.
Some error occurred, and it said "ReferenceError: assert is not defined".
Using bin/unzip.min.js
in PhantomJS, I get:
Uncaught TypeError: '[object Uint8Array]' is not a valid argument for 'Function.prototype.apply' (evaluating 'a.slice(b,b+=this.h)') (file:///Users/dave/Sites/repos/filer/lib/unzip.js:24)
It is this pattern: https://github.com/imaya/zlib.js/blob/master/src/unzip.js#L203-L205
String.fromCharCode.apply(null, USE_TYPEDARRAY ?
input.subarray(ip, ip += this.fileNameLength) :
input.slice(ip, ip += this.fileNameLength)
);
The pdf.js guys had a similar issue, see mozilla/pdf.js#1820. It's a bug in old Chrome/WebKits.
i paste the zlib.min.js source code in my chrome devtool console, and find some weird behavior:
also the zlib.deflate produce incompatible data for python zlib lib to decompress.
To process big files I want to inflate only chunks of data to a buffer. The output buffer has a fixed size of let's say 1024 bytes. Now I don't know what function to use in order to produce an output of 1024 bytes.
Is there anything available to achieve this or will I need to write some buffer mechanism myself?
I use Zlib.InflateStream()
in my project. I made a new instance of this at top of my file and want to use it multiple times to decompress different UInt8Arrays.
When I call decompress
the first time, everything works like expectet. When I call it a second time on the same buffer, it will return an uncompressed buffer, but the length is smaller. When I call it a third time (same UInt8Array again) decompress() returns a buffer that length is 0.
To work around this I have to make a new Instance of Zlib.InflateStream()
everytime I want to call inflator.decompress()
Firefox gave me this warning:
JavaScript warning: deflate.min.js, line 25: Using //@ to indicate source map URL pragmas is deprecated. Use //# instead
buster is only used in tests, so it should not be included as dependencies (it will be installed even if you run npm install --production zlibjs
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.