Replies: 1 comment
-
There's no // concat([idats[0], idats[1], ...]) concatenates all of the buffers into one
var concat = function(u8Arrays) {
var finalLen = 0;
for (var i = 0; i < u8Arrays.length; ++i) {
finalLen += u8Arrays[i].length;
}
var result = new Uint8Array(finalLen);
for (var i = 0, offset = 0; i < u8Arrays.length; ++i) {
result.set(u8Arrays[i], offset);
offset += u8Arrays[i].byteLength;
}
return result;
} You can use this in one of two ways. If you have all your IDATs up front, use like this: var srcData = fflate.unzlibSync(concat(idats)); If you still need to add the IDATs one at a time (e.g. if you're decompressing as you read them sequentially from a file), use like this: var chunks = [];
var inflator = new fflate.Unzlib(function(chunk, final) {
chunks.append(chunk);
});
inflator.push(idat0);
inflator.push(idat1);
// ...
inflator.push(idatEnd, true);
var srcData = concat(chunks); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With pako I used to do this to decode PNG files. PNG can use several IDAT chunks for data.
Beta Was this translation helpful? Give feedback.
All reactions