npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

xz-compat

v1.2.11

Published

XZ Decompression Library

Readme

xz-compat

Decompress XZ, LZMA, and LZMA2 data in Node.js. The package has a pure JavaScript fallback, optional native acceleration, and exports BCJ and Delta filters.

npm install xz-compat

The package targets Node.js 0.8 and newer. Use the CommonJS entry point on older Node.js versions; the ESM examples below require a runtime that supports ESM.

XZ files

import { readFileSync } from 'fs';
import { decodeXZ } from 'xz-compat';

const output = await decodeXZ(readFileSync('input.xz'));
console.log(output.length); // decompressed byte count

For large files, use the streaming transform:

import { createReadStream, createWriteStream } from 'fs';
import { createXZDecoder } from 'xz-compat';

createReadStream('input.xz')
  .pipe(createXZDecoder())
  .pipe(createWriteStream('output'));

Public API

| Export | Use | | --- | --- | | decodeXZ(buffer) | Decode a complete XZ container. Returns a promise for a Buffer-like result. | | createXZDecoder() | Create a streaming XZ transform. | | decode7zLzma(data, properties, unpackSize) | Decode raw LZMA data from a 7z entry. | | decode7zLzma2(data, properties, unpackSize?) | Decode raw LZMA2 data from a 7z entry. | | decodeLzma(data, properties, outSize, sink?) | Decode raw LZMA data synchronously. | | decodeLzma2(data, properties, unpackSize, sink?) | Decode raw LZMA2 data synchronously. | | createLzmaDecoder(properties, outSize) | Create a streaming LZMA transform. | | createLzma2Decoder(properties, unpackSize?) | Create a streaming LZMA2 transform. | | decodeBcj*, createBcj*Decoder | Decode or stream supported x86, ARM, ARM64, ARM Thumb, PowerPC, SPARC, and IA64 BCJ filters. | | decodeDelta(buffer, distance?) | Decode a byte-level Delta filter. | | isNativeAvailable() | Check whether the optional native decoder can load. |

The low-level LZMA APIs require codec properties and, for LZMA1, the expected output size. The 7z APIs accept those properties separately because that is how the 7z format stores them.

Optional native acceleration

On Node.js 14 and newer, the decoder can use lzma-native on supported platforms. It falls back to JavaScript when the native module is unavailable. Native loading may try to install the module dynamically. Set LZMA_NATIVE_DISABLE=1 to prevent that attempt.

The native path has no measured speed guarantee. Choose it for a native implementation when available, not for a fixed performance multiplier.

Limits

This package decompresses; it does not create XZ or LZMA archives. Browser support is not tested.

License

MIT