A library for working with archive files, providing utilities for compressing and decompressing data.
Go to file
2024-06-08 10:30:05 +02:00
.gitea/workflows BREAKING CHANGE(core): update 2023-11-06 18:14:21 +01:00
.vscode fix(core): update 2023-07-26 16:13:33 +02:00
dist_ts BREAKING CHANGE(core): update 2023-11-06 18:14:21 +01:00
test fix(core): update 2023-11-14 10:58:01 +01:00
ts fix(core): update 2024-06-08 10:30:03 +02:00
.gitignore fix(core): update 2020-03-16 15:13:58 +00:00
license fix(core): update 2023-11-11 18:28:50 +01:00
npmextra.json update tsconfig 2024-04-14 17:20:20 +02:00
package.json 4.0.25 2024-06-08 10:30:05 +02:00
pnpm-lock.yaml fix(core): update 2024-06-08 10:30:03 +02:00
readme.hints.md update tsconfig 2024-04-14 17:20:20 +02:00
readme.md update tsconfig 2024-04-14 17:20:20 +02:00
test.js added callback support 2016-01-20 04:01:21 +01:00
tsconfig.json BREAKING CHANGE(core): update 2023-11-06 18:14:21 +01:00

@push.rocks/smartarchive

work with archives

Install

To install @push.rocks/smartarchive, you need to use npm or yarn. Run either of the following commands in your project directory:

npm install @push.rocks/smartarchive --save

or if you prefer yarn:

yarn add @push.rocks/smartarchive

This will add @push.rocks/smartarchive to your project's dependencies.

Usage

@push.rocks/smartarchive is a powerful module designed to simplify the process of working with archive files such as zip, tar, gzip, and more. It provides an easy-to-use API for extracting, creating, and analyzing archives, making it an ideal choice for projects that require manipulation of archive files.

Getting Started

First, import SmartArchive from @push.rocks/smartarchive using ESM syntax:

import { SmartArchive } from '@push.rocks/smartarchive';

Extracting Archive Files

To extract an archive file, you can use SmartArchive.fromArchiveUrl, SmartArchive.fromArchiveFile, or SmartArchive.fromArchiveStream methods depending on the source of your archive. Here's an example of extracting an archive from a URL:

async function extractArchiveFromURL() {
  const url = 'https://example.com/archive.zip';
  const targetDir = '/path/to/extract';

  const archive = await SmartArchive.fromArchiveUrl(url);
  await archive.exportToFs(targetDir);

  console.log('Archive extracted successfully.');
}

Creating Archive Files

Creating archive files such as zip or tar.gz is straightforward with smartarchive. At the moment, you'll prepare the contents programmatically and then compress them. Detailed support for creating archives will be covered in future updates.

Analyzing Archive Files

Analyzing the content of archives without extracting them can be useful in various scenarios, such as when you need to inspect the archive's content before deciding to extract it. Here's how you might analyze an archive:

async function analyzeArchive() {
  const url = 'https://example.com/archive.zip';
  
  const archive = await SmartArchive.fromArchiveUrl(url);
  const analysisResult = await archive.analyzeContent();
  
  console.log(analysisResult); // Outputs details about the archive content
}

Note: Replace analyzeContent with the appropriate method calls as per your implementation or update, as smartarchive provides foundational classes and methods for interaction with archive files but does not directly implement an analyzeContent method by default.

Stream Operations

smartarchive offers streaming operations, allowing you to work with large archives efficiently. Here's an example of using streams to extract an archive:

import { createReadStream, createWriteStream } from 'fs';

async function extractArchiveUsingStream() {
  const archiveStream = createReadStream('/path/to/archive.zip');
  const archive = await SmartArchive.fromArchiveStream(archiveStream);
  const extractionStream = await archive.exportToStreamOfStreamFiles();
  
  extractionStream.pipe(createWriteStream('/path/to/destination'));
}

Conclusion

@push.rocks/smartarchive simplifies the process of working with various archive formats in JavaScript and TypeScript projects. By providing an easy-to-use API for common archive operations, it enables developers to integrate archive manipulation features into their applications efficiently.

Remember, the examples provided here are to give you a starting point. Depending on your specific use case, you may need to adjust these examples to fit your project's requirements. Always refer to the latest documentation for the most current information and methods available in @push.rocks/smartarchive.

For more information and API references, check the official @push.rocks/smartarchive GitHub repository.

This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the license file within this repository.

Please note: The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

Trademarks

This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.

Company Information

Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany

For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.

By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.