![]() ![]() ![]() It's not required if you just want to use xzwasm.WinZip ® provides several methods for compressing the files that you add to a Zip file. Note: This is only needed if you want to work on xzwasm itself. tar file, and then pass this data to another library such as js-untar or tarballjs to get the bundled files. tar.xz stream to a stream representing the. However, you can use xzwasm to convert a. Xzwasm doesn't have built-in support for. xz format only represents one file, it's common for people to bundle up a collection of files as. xz data using xzwasm, on Chromium, takes roughly 3x as long as Chromium's native Brotli decompressor.Īs for whether this is a good tradeoff for you, see Why would anyone do this? What about. So, of course, you only make a net gain on bandwidth if you're saving more than 8 KB by using XZ compression.ĭecompressing. The JavaScript/WebAssembly code in this library weighs just under 8 KB if served with Brotli compression. It's tested on current versions of Firefox, Chrome, Edge, and Safari. This should work on any moderately recent browser. For example, new xzwasm.XzReadableStream(compressedResponse.body). Note: If you're using a tag to reference xzwasm, you probably need to prefix XzReadableStream with xzwasm. The API is designed to be as JavaScript-standard as possible, so XzReadableStream is a ReadableStream instance, which in turn means you can feed it into a Response, and in turn get a blob, an ArrayBuffer, JSON data, or anything else that you browser can do with a Response. arrayBuffer(): const text = await decompressedResponse. body ) ) // We now have a regular Response object, so can use standard APIs to parse its body data, // such as. Installation Option 1: As an NPM packageĬonst compressedResponse = await fetch ( 'somefile.xz' ) const decompressedResponse = new Response ( new XzReadableStream ( compressedResponse. It's also a good demonstration of how a technology like WebAssembly can effectively extend the capabilities of a browser. But it would be nice if browsers supported XZ natively. In most applications the added complexity of XZ via a custom decompressor library won't be worth the small bandwidth saving. XZ can be 5-10x faster to compress than Brotli, especially at the highest compression level.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |