file-compressor-ts
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

File Compressor

Overview

This is a package to compress any file in TypeScript.

Features

  • Compression Algorithm: Compresses files using the zlib compression algorithm.
  • File Format Support: Supports various file formats, such as text files, JSON files, and binary files.
  • Integrity Preservation: Maintains file integrity during compression.
  • Error Handling: Provides error handling for any issues that may arise during the compression process.

Installation

npm install file-compressor

Usage

import {compressFile} from 'file-compressor';

void compressFile({
    inputPath: 'input.txt',
    outputPath: 'output.gz',
}).then((response) => {
    if (response.state === 'successful') {
        console.log('File compressed successfully!');
    } else {
        console.error('Error compressing file:', response.error);
    }
}).catch((error) => {
    console.error('Error compressing file:', error);
});

You can call the compressFile function and pass it an object containing the input and output file paths (inputPath and outputPath).

The function returns a promise that will be resolved with either a successful or rejected result. You can use .then to handle the successful case and .catch to handle errors.

Package Sidebar

Install

npm i file-compressor-ts

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

14.8 kB

Total Files

14

Last publish

Collaborators

  • m.gese