This is a fork of Nathan Rugg's package that adds types and makes the logic more structured and readable.
Note
This package is native ESM and no longer provides a
CommonJS export. If your project uses CommonJS, you will have to convert to ESM
or use the dynamic import()
function.
npm install lzma1
Since v1.28+
import from npm registry using npm:
prefix.
import {
compress,
decompress,
} from "npm:lzma1@latest";
<script type="module">
import { compress, decompress } from "https://esm.sh/lzma1@latest";
</script>
compress(data: string | Uint8Array, mode?: Mode): Int8Array
decompress(data: Uint8Array | ArrayBuffer): string | Int8Array
Compress and decompress a string with compression level 1.
import {
compress,
decompress,
} from "lzma1";
const data = "Hello World!";
const compressed = compress(data, 1);
const decompressed = decompress(result);
// data === decompressed
More information about the LZMA header.