I am new to Stackoverflow. I am now working on a node.js program. The input is a data stream containing few blocks of data (also zipped by DEFLATE algorithm) concatenated together. My goal is use INFLATE to restore the data blocks and put them into correct orders.
My problem is, when I use while loop to do extraction of data blocks, the data extracted is not in the order I input. Why?
while (initPointer < totalLength) {
...
console.log('Extracting '+rawLengthBuf.readUInt32LE(0));
...
zlib.inflate(dataBuf, function(err, data) {
if (!err) {
console.log('Extracted '+data.length);
}
});
}
Output:
Extracting 18876
Extracting 15912
Extracting 10608
Extracted 15912
Extracted 10608
Extracted 18876
Please forgive me that I may not describe the situation in very clear way. Thanks.