node-lzma7z
v0.1.2
Published
Create password-protected and split 7z archives using LZMA SDK 26.00 (N-API native addon)
Maintainers
Readme
node-lzma7z
Create 7z archives with optional AES password protection, header encryption, split volumes, and configurable LZMA compression level, via an N-API native addon built from LZMA SDK 26.00 (7-Zip reduced variant).
Requirements
- Node.js ≥ 18
- node-gyp build toolchain: Python 3, a C++ compiler (GCC/Clang on Linux/macOS, MSVC on Windows), and
makewhere applicable
npm install runs node-gyp rebuild automatically.
Install
npm install node-lzma7zAPI
compress7z(options, callback)
Asynchronous compression. callback receives (err).
compress7zSync(options)
Synchronous compression; throws on failure.
Options (Compress7zOptions)
| Property | Type | Description |
|----------|------|-------------|
| outputPath | string | Path for the .7z file. For split archives, volume names are derived from this path (e.g. out.7z.001, out.7z.002). |
| inputs | string[] | Files and/or directories to add; directories are included recursively. |
| password | string (optional) | If set, the archive is encrypted with AES. |
| encryptHeaders | boolean (optional) | When used with password, enables header encryption (-mhe=on). |
| compressionLevel | number (optional) | 0–9; default 5. |
| volumeSizeBytes | number (optional) | If > 0, splits output into volumes of that size in bytes (last volume may be smaller). |
Example
const { compress7z, compress7zSync } = require('node-lzma7z');
const path = require('path');
// Async
compress7z(
{
outputPath: path.join(__dirname, 'backup.7z'),
inputs: [path.join(__dirname, 'data')],
password: 'your-secret',
encryptHeaders: true,
compressionLevel: 7,
volumeSizeBytes: 10 * 1024 * 1024, // 10 MiB per volume
},
(err) => {
if (err) throw err;
console.log('done');
}
);
// Sync
compress7zSync({
outputPath: '/tmp/out.7z',
inputs: ['/tmp/file1.txt', '/tmp/file2.txt'],
});TypeScript
Types are published in index.d.ts (Compress7zOptions, compress7z, compress7zSync).
Test
npm testThe test builds a small encrypted, split archive and optionally verifies listing with 7z or 7zz if present on PATH.
License
See package.json (Unlicense). The bundled LZMA / 7-Zip sources follow their respective licenses in the SDK tree.
