{"id":19738269,"url":"https://github.com/httptoolkit/xz-decompress","last_synced_at":"2025-10-06T16:30:38.124Z","repository":{"id":173170091,"uuid":"650306125","full_name":"httptoolkit/xz-decompress","owner":"httptoolkit","description":" XZ decompression for the browser \u0026 Node without native code, via WebAssembly","archived":false,"fork":false,"pushed_at":"2025-07-17T09:43:50.000Z","size":1438,"stargazers_count":15,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-14T23:17:12.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/httptoolkit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-06T19:39:10.000Z","updated_at":"2025-08-15T22:09:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"72d6d299-e825-4f48-8610-05118e1a818a","html_url":"https://github.com/httptoolkit/xz-decompress","commit_stats":null,"previous_names":["httptoolkit/xz-decompress"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/httptoolkit/xz-decompress","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fxz-decompress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fxz-decompress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fxz-decompress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fxz-decompress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/httptoolkit","download_url":"https://codeload.github.com/httptoolkit/xz-decompress/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fxz-decompress/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278643277,"owners_count":26021074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T01:13:44.458Z","updated_at":"2025-10-06T16:30:38.118Z","avatar_url":"https://github.com/httptoolkit.png","language":"JavaScript","readme":"# XZ-Decompress - Streaming XZ decompression for the browser \u0026 Node [![Build Status](https://github.com/httptoolkit/xz-decompress/workflows/CI/badge.svg)](https://github.com/httptoolkit/xz-decompress/actions)\n\n\u003e _Part of [HTTP Toolkit](https://httptoolkit.com): powerful tools for building, testing \u0026 debugging HTTP(S)_\n\nThis is an NPM package compatible with both Node.js \u0026 browsers that can decompress XZ streams.\n\nYou can use this if you want your web server to return XZ-encoded content and have your JavaScript code see the uncompressed data (as an alternative to Gzip or Brotli), or if you want to decompress XZ files within Node.js without needing to mess with any native addons.\n\n_This is a fork of https://github.com/SteveSanderson/xzwasm, intended for use in [Frida-JS](https://github.com/httptoolkit/frida-js/) and [HTTP Toolkit](https://httptoolkit.com)._\n\n## Installation\n\n```\nnpm install --save xz-decompress\n```\n\nYou can then import things from `xz-decompress` in your existing JavaScript/TypeScript files. Example:\n\n```js\nimport { XzReadableStream } from 'xz-decompress';\n```\n\n## How to use\n\nGiven an XZ-compressed stream, such as a `fetch` response body, you can get a decompressed response by wrapping it with `XzReadableStream`. Example:\n\n```js\nconst compressedResponse = await fetch('somefile.xz');\n\nconst decompressedResponse = new Response(\n   new XzReadableStream(compressedResponse.body)\n);\n\n// We now have a regular Response object, so can use standard APIs to parse its body data,\n// such as .text(), .json(), or .arrayBuffer():\nconst text = await decompressedResponse.text();\n```\n\nThe API is designed to be as JavaScript-standard as possible, so `XzReadableStream` is a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) instance, which in turn means you can feed it into a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response), and in turn get a blob, an ArrayBuffer, JSON data, or anything else that your runtime can do with a `Response`.\n\nIf you're using this to decompress content from a file or other source, rather than an HTTP response body, you'll need to get a `ReadableStream` (a web stream) for the file's data to replace the `compressedResponse.body` stream above. For example, in Node.js you could use `Readable.toWeb(fs.createReadStream(filename))` to stream from the disk, or `new Blob([buffer]).stream()` if you already have the data in a `Buffer`.\n\n## What about `.tar.xz` files?\n\nSince the `.xz` format only represents one file, it's common for people to bundle up a collection of files as `.tar`, and then compress this to `.tar.xz`.\n\nXZ-Decompress doesn't have built-in support for `.tar`. However, you can use it to convert a `.tar.xz` stream to a stream representing the `.tar` file, and then pass this data to another library such as [js-untar](https://github.com/InvokIT/js-untar) or [tarballjs](https://github.com/ankitrohatgi/tarballjs) to get the bundled files.\n\n## Building code in this repo\n\n**Note:** This is only needed if you want to work on xz-decompress itself, not if you just want to use it.\n\n * Clone this repo\n * Clone/update submodules\n    * `git submodule update --init --recursive`\n * Ensure you have a working Clang toolchain that can build wasm\n    * If running on Linux: `npm run setup-wasi-sdk`\n    * Otherwise you can install https://github.com/WebAssembly/wasi-sdk and `export wasisdkroot=/path/to/wasi-sdk`\n * (For testing only) Ensure you have `xz` and `brotli` available as commands on $PATH\n * Run `make`\n\n### Building the NPM package contents\n\n * Have `node` installed\n * `npm install`\n * Run `make package`\n\n### Running scenario/perf tests\n\n * Have `node` installed\n * `npm install -g http-server`\n * `make run-sample`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttptoolkit%2Fxz-decompress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhttptoolkit%2Fxz-decompress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttptoolkit%2Fxz-decompress/lists"}