Giter Site home page Giter Site logo

Support "deflate-raw" format about compression HOT 10 CLOSED

ricea avatar ricea commented on August 16, 2024 4
Support "deflate-raw" format

from compression.

Comments (10)

yutakahirano avatar yutakahirano commented on August 16, 2024 4

Chrome is interested in this feature, and wants to add this feature. Are there any opinions from other browser vendors?

from compression.

taralx avatar taralx commented on August 16, 2024

Note that zip files can be decompressed (and checksummed!) using gzip:

const GZIP_HEADER = Uint8Array.from([
  31, 139, // gzip magic
  8, // deflate
  0, // no extra fields
  0, 0, 0, 0, // mtime (n/a)
  0, 0, // extra flags, OS
]);

function decompressZip(stream, crc, uncompressedSize) {
  return stream.pipeThrough(new TransformStream({
    start(controller) {
      controller.enqueue(GZIP_HEADER);
    },
    flush(controller) {
      const tmp = new DataView(new ArrayBuffer(8));
      tmp.setUint32(0, crc, true);
      tmp.setUint32(4, uncompressedSize, true);
      controller.enqueue(new Uint8Array(tmp.buffer));
    }
  })).pipeThrough(new DecompressionStream('gzip'));
}

from compression.

taralx avatar taralx commented on August 16, 2024

Note that for the creation side, you need CRC, so you may as well use gzip there too.

from compression.

ricea avatar ricea commented on August 16, 2024

@taralx That's impressive, but I'd prefer it if people didn't have to put together a fake gzip wrapper just to decode a zip file.

I like the CRC trick. It doesn't look like there'd be an easy way to get the same functionality with "deflate-raw".

from compression.

taralx avatar taralx commented on August 16, 2024

In decompression it can be a constructor option. In compression though, I'm not sure either.

from compression.

panva avatar panva commented on August 16, 2024

I am likewise looking for support of 'inflate-raw' and 'deflate-raw' formats.

from compression.

nikhil1511 avatar nikhil1511 commented on August 16, 2024

We are also interested in having support for "deflate-raw" as it is required for zipping. With "gzip" or "deflate" formats, additional workarounds would be required which is not very neat. So, it would be super helpful if raw compression format can be supported.
Thanks!

from compression.

yutakahirano avatar yutakahirano commented on August 16, 2024

Working at #43. Any feedbacks will be appreciated.

from compression.

yutakahirano avatar yutakahirano commented on August 16, 2024

@ricea I cannot close this, but I think this can be closed now.

from compression.

ricea avatar ricea commented on August 16, 2024

Done.

from compression.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.