augustl / js-inflate Goto Github PK
View Code? Open in Web Editor NEWInflate (uncompress) blobs compressed with the deflate algorithm
Inflate (uncompress) blobs compressed with the deflate algorithm
I've compressed following string using DeflateStream in C# :"<Some test string"
Base64 output is this: swnOz01VKEktLlEoLinKzEsHAA==
But this string won't inflate (or any other string which starts with < like html document).
If I try with string "Some test string"
its compressed to: C87PTVUoSS0uUSguKcrMSwcA
and it works just fine.
Hi @augustl,
have you considered porting this library for TypedArrays (specifically Uint8Array)?
For a zip with xml file alone I got the entry properly but if I give that as input for inflate uncompressed = JSInflate.inflate(entry.data); (where entry = unzipper.entries[0]). I am getting uncompressed data as empty.
i.e. inflate is resulting empty data.
Please review and suggest.
I may be doing something incredibly wrong, but I figured I'd post this in case you've seen it before. I cannot seem to get this library to work with any of my zip files. Whenever I call JSInflate.inflate
on a zipped entry (from the js-unzip library), my processor gets pegged at 100% and it seems to be causing an infinite loop in this: while((i = zip_inflate_internal(buff, 0, buff.length)) > 0)
Here is my full code:
$('input:file').live('change', function() {
var file = this.files[0],
r = new FileReader();
r.onload = function(e) {
var unzipper = new JSUnzip(r.result);
if (unzipper.isZipFile()) {
unzipper.readEntries();
for (var i = 0, var len = unzipper.entries.length; i < len; i++) {
var entry = unzipper.entries[i];
getEntry(entry);
}
}
r.readAsBinaryString(file);
});
getEntry = function(entry) {
var uncompressed;
if (entry.fileName.match(/some_file_name/)) {
if (entry.compressionMethod == 0) {
// Uncompressed
uncompressed = entry.data
} else if (entry.compressionMethod == 8) {
// Deflated
console.log('inflating...');
uncompressed = JSInflate.inflate(entry.data);
console.log(uncompressed);
}
};
As you can see, I'm only trying to uncompress one file within the Zip (and it's a small 1.5KB text file). It get's to the inflating...
line, but that's when the CPU gets pegged in Chrome (in FF, it'll say the script has stopped responding). Putting some debug code in js-inflate, it looks like the aforementioned line is infinite-looping.
Also, I tried the dankogai/js-deflate library, and it does the exact same thing.
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.