node-liblzma
Version:
NodeJS wrapper for liblzma
245 lines • 9.35 kB
TypeScript
/**
* node-liblzma - Node.js bindings for liblzma
* Copyright (C) Olivier Orabona <olivier.orabona@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Transform, type TransformCallback, type TransformOptions } from 'node:stream';
import type { NativeLZMA } from '../index.js';
import { LZMABufferError, LZMADataError, LZMAError, LZMAFormatError, LZMAMemoryError, LZMAMemoryLimitError, LZMAOptionsError, LZMAProgrammingError } from './errors.js';
import type { CheckType, CompressionCallback, FilterType, LZMAActionType, LZMAOptions, LZMAStatusType, ModeType, PresetType } from './types.js';
export { LZMAError, LZMAMemoryError, LZMAMemoryLimitError, LZMAFormatError, LZMAOptionsError, LZMADataError, LZMABufferError, LZMAProgrammingError, };
export { LZMAPool, type PoolMetrics } from './pool.js';
export declare const check: {
readonly NONE: any;
readonly CRC32: any;
readonly CRC64: any;
readonly SHA256: any;
};
export declare const preset: {
readonly DEFAULT: any;
readonly EXTREME: any;
};
export declare const flag: {
readonly TELL_NO_CHECK: any;
readonly TELL_UNSUPPORTED_CHECK: any;
readonly TELL_ANY_CHECK: any;
readonly CONCATENATED: any;
};
export declare const filter: {
readonly LZMA2: any;
readonly X86: any;
readonly POWERPC: any;
readonly IA64: any;
readonly ARM: any;
readonly ARMTHUMB: any;
readonly SPARC: any;
};
export declare const mode: {
readonly FAST: any;
readonly NORMAL: any;
};
export declare const LZMAAction: {
readonly RUN: any;
readonly SYNC_FLUSH: any;
readonly FULL_FLUSH: any;
readonly FINISH: any;
};
export declare const LZMAStatus: {
readonly OK: any;
readonly STREAM_END: any;
readonly NO_CHECK: any;
readonly UNSUPPORTED_CHECK: any;
readonly GET_CHECK: any;
readonly MEM_ERROR: any;
readonly MEMLIMIT_ERROR: any;
readonly FORMAT_ERROR: any;
readonly OPTIONS_ERROR: any;
readonly DATA_ERROR: any;
readonly BUF_ERROR: any;
readonly PROG_ERROR: any;
};
export declare const LZMAFilter: {
readonly X86_ALT: any;
readonly POWERPC_ALT: any;
readonly IA64_ALT: any;
readonly ARM_ALT: any;
readonly ARMTHUMB_ALT: any;
readonly FILTERS_MAX: any;
readonly LZMA2: any;
readonly X86: any;
readonly POWERPC: any;
readonly IA64: any;
readonly ARM: any;
readonly ARMTHUMB: any;
readonly SPARC: any;
};
export declare const LZMA_RUN: any;
export declare const LZMA_SYNC_FLUSH: any;
export declare const LZMA_FULL_FLUSH: any;
export declare const LZMA_FINISH: any;
export declare const LZMA_OK: any;
export declare const LZMA_STREAM_END: any;
export declare const LZMA_NO_CHECK: any;
export declare const LZMA_UNSUPPORTED_CHECK: any;
export declare const LZMA_GET_CHECK: any;
export declare const LZMA_MEM_ERROR: any;
export declare const LZMA_MEMLIMIT_ERROR: any;
export declare const LZMA_FORMAT_ERROR: any;
export declare const LZMA_OPTIONS_ERROR: any;
export declare const LZMA_DATA_ERROR: any;
export declare const LZMA_BUF_ERROR: any;
export declare const LZMA_PROG_ERROR: any;
export declare const LZMA_FILTER_X86: any;
export declare const LZMA_FILTER_POWERPC: any;
export declare const LZMA_FILTER_IA64: any;
export declare const LZMA_FILTER_ARM: any;
export declare const LZMA_FILTER_ARMTHUMB: any;
export declare const LZMA_FILTERS_MAX: any;
export type { LZMAOptions, CompressionCallback, LZMAActionType, LZMAStatusType, CheckType, PresetType, FilterType, ModeType, };
export declare abstract class XzStream extends Transform {
protected _opts: Required<LZMAOptions>;
protected _chunkSize: number;
protected _flushFlag: number;
protected lzma: NativeLZMA;
protected _closed: boolean;
protected _hadError: boolean;
protected _offset: number;
protected _buffer: Buffer;
constructor(streamMode: number, opts?: LZMAOptions, options?: TransformOptions);
private _createLZMAError;
private _reallocateBuffer;
flush(callback?: () => void): void;
flush(kind: number, callback?: () => void): void;
close(callback?: () => void): void;
_transform(chunk: Buffer | null, _encoding: string, callback: TransformCallback): void;
_flush(callback: TransformCallback): void;
_processChunk(chunk: Buffer | null, flushFlag: number, cb?: TransformCallback): Buffer | undefined;
}
export declare class Xz extends XzStream {
constructor(lzmaOptions?: LZMAOptions, options?: TransformOptions);
}
export declare class Unxz extends XzStream {
constructor(lzmaOptions?: LZMAOptions, options?: TransformOptions);
}
export declare function createXz(lzmaOptions?: LZMAOptions, options?: TransformOptions): Xz;
export declare function createUnxz(lzmaOptions?: LZMAOptions, options?: TransformOptions): Unxz;
export declare function hasThreads(): boolean;
export declare enum LZMAErrorMessage {
SUCCESS = "Operation completed successfully",
STREAM_END = "End of stream was reached",
NO_CHECK = "Input stream has no integrity check",
UNSUPPORTED_CHECK = "Cannot calculate the integrity check",
GET_CHECK = "Integrity check type is not available",
MEM_ERROR = "Cannot allocate memory",
MEMLIMIT_ERROR = "Memory usage limit was reached",
FORMAT_ERROR = "File format not recognized",
OPTIONS_ERROR = "Invalid or unsupported options",
DATA_ERROR = "Data is corrupt",
BUF_ERROR = "No progress is possible",
PROG_ERROR = "Programming error"
}
export declare const messages: readonly string[];
export declare function unxz(buffer: Buffer | string, callback: CompressionCallback): void;
export declare function unxz(buffer: Buffer | string, opts: LZMAOptions, callback: CompressionCallback): void;
export declare function unxzSync(buffer: Buffer | string, opts?: LZMAOptions): Buffer;
export declare function xz(buffer: Buffer | string, callback: CompressionCallback): void;
export declare function xz(buffer: Buffer | string, opts: LZMAOptions, callback: CompressionCallback): void;
export declare function xzSync(buffer: Buffer | string, opts?: LZMAOptions): Buffer;
export declare function xzAsync(buffer: Buffer | string, opts?: LZMAOptions): Promise<Buffer>;
export declare function unxzAsync(buffer: Buffer | string, opts?: LZMAOptions): Promise<Buffer>;
/**
* Compress a file using XZ compression
* @param inputPath Path to input file
* @param outputPath Path to output compressed file
* @param opts LZMA compression options
* @returns Promise that resolves when compression is complete
*/
export declare function xzFile(inputPath: string, outputPath: string, opts?: LZMAOptions): Promise<void>;
/**
* Decompress an XZ compressed file
* @param inputPath Path to compressed input file
* @param outputPath Path to output decompressed file
* @param opts LZMA decompression options
* @returns Promise that resolves when decompression is complete
*/
export declare function unxzFile(inputPath: string, outputPath: string, opts?: LZMAOptions): Promise<void>;
declare const _default: {
Xz: typeof Xz;
Unxz: typeof Unxz;
XzStream: typeof XzStream;
hasThreads: typeof hasThreads;
messages: readonly string[];
check: {
readonly NONE: any;
readonly CRC32: any;
readonly CRC64: any;
readonly SHA256: any;
};
preset: {
readonly DEFAULT: any;
readonly EXTREME: any;
};
flag: {
readonly TELL_NO_CHECK: any;
readonly TELL_UNSUPPORTED_CHECK: any;
readonly TELL_ANY_CHECK: any;
readonly CONCATENATED: any;
};
filter: {
readonly LZMA2: any;
readonly X86: any;
readonly POWERPC: any;
readonly IA64: any;
readonly ARM: any;
readonly ARMTHUMB: any;
readonly SPARC: any;
};
mode: {
readonly FAST: any;
readonly NORMAL: any;
};
createXz: typeof createXz;
createUnxz: typeof createUnxz;
unxz: typeof unxz;
unxzSync: typeof unxzSync;
xz: typeof xz;
xzSync: typeof xzSync;
xzAsync: typeof xzAsync;
unxzAsync: typeof unxzAsync;
LZMA_RUN: any;
LZMA_SYNC_FLUSH: any;
LZMA_FULL_FLUSH: any;
LZMA_FINISH: any;
LZMA_OK: any;
LZMA_STREAM_END: any;
LZMA_NO_CHECK: any;
LZMA_UNSUPPORTED_CHECK: any;
LZMA_GET_CHECK: any;
LZMA_MEM_ERROR: any;
LZMA_MEMLIMIT_ERROR: any;
LZMA_FORMAT_ERROR: any;
LZMA_OPTIONS_ERROR: any;
LZMA_DATA_ERROR: any;
LZMA_BUF_ERROR: any;
LZMA_PROG_ERROR: any;
LZMA_FILTER_X86: any;
LZMA_FILTER_POWERPC: any;
LZMA_FILTER_IA64: any;
LZMA_FILTER_ARM: any;
LZMA_FILTER_ARMTHUMB: any;
LZMA_FILTERS_MAX: any;
};
export default _default;
//# sourceMappingURL=lzma.d.ts.map