Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Decompressing just the start of a block of compressed data  #75

@sheffieldnikki

Description

@sheffieldnikki

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions