- 
                Notifications
    
You must be signed in to change notification settings  - Fork 130
 
Open
Description
For a project I wanted to synchronously extract just the initial 4 KB of text from the start of some compressed data, render that quickly for the user, and then (separately) decompress the entire data asynchronously.
Here is a little hack that does just that. eg, for inserting into lzma-d.js:
    /** returns up to max_bytes of decompressed data */
    function decompresschunk(byte_arr, max_bytes) {
        var this$static = {};
        this$static.d = $LZMAByteArrayDecompressor({}, byte_arr);
        while ($processChunk(this$static.d.chunker) && this$static.d.chunker.outBytesProcessed[0] < max_bytes);
        if (this$static.d.chunker.alive)
            $Flush_0(this$static.d.chunker.decoder.m_OutWindow);
        return decode($toByteArray(this$static.d.output));      
    }Metadata
Metadata
Assignees
Labels
No labels