All Projects → nika-begiashvili → Libarchivejs

nika-begiashvili / Libarchivejs

Licence: mit
Archive library for browsers

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Libarchivejs

ratarmount
Random Access Read-Only Tar Mount
Stars: ✭ 217 (+49.66%)
Mutual labels:  gzip, zip, extract, tar
Archiver
Easily create & extract archives, and compress & decompress files of various formats
Stars: ✭ 3,373 (+2226.21%)
Mutual labels:  extract, zip, tar, gzip
zzlib
zlib-compressed file depacking library in Lua
Stars: ✭ 44 (-69.66%)
Mutual labels:  gzip, zip, extract
zipstream
A command line tool that allows you to easily share files and directories over the network
Stars: ✭ 49 (-66.21%)
Mutual labels:  gzip, zip, tar
bled
Base Library for Easy Decompression
Stars: ✭ 21 (-85.52%)
Mutual labels:  gzip, zip, decompression
Unifiedarchive
UnifiedArchive - an archive manager with a unified way for different formats. Supports all basic (listing, reading, extracting and creation) and specific features (compression level, password-protection). Bundled with console program for working with archives.
Stars: ✭ 246 (+69.66%)
Mutual labels:  zip, tar, gzip
compress
compress and uncompress for Deno
Stars: ✭ 29 (-80%)
Mutual labels:  gzip, zip, tar
Denoflate
WebAssembly powered Deflate/Gzip/Zlib compression for Deno, written in Rust
Stars: ✭ 80 (-44.83%)
Mutual labels:  webassembly, wasm, gzip
Leanify
lightweight lossless file minifier/optimizer
Stars: ✭ 694 (+378.62%)
Mutual labels:  zip, tar, gzip
Php Zip
PhpZip is a php-library for extended work with ZIP-archives.
Stars: ✭ 336 (+131.72%)
Mutual labels:  extract, zip, archive
Percy
Build frontend browser apps with Rust + WebAssembly. Supports server side rendering.
Stars: ✭ 1,856 (+1180%)
Mutual labels:  webassembly, wasm, browser
Sharpcompress
SharpCompress is a fully managed C# library to deal with many compression types and formats.
Stars: ✭ 1,397 (+863.45%)
Mutual labels:  zip, tar, gzip
Bit7z
A C++ static library offering a clean and simple interface to the 7-zip DLLs.
Stars: ✭ 159 (+9.66%)
Mutual labels:  zip, tar, gzip
ZeeArchiver
Zee is an efficient and simple to use Android Archiver and decompressor. It can decompress and compress from-to all the formats supported by the well known 7zip utility. Copyright © 2018 Mahmoud Galal , for support contact me:[email protected]
Stars: ✭ 35 (-75.86%)
Mutual labels:  zip, extract, archive
Compress
Optimized Go Compression Packages
Stars: ✭ 2,478 (+1608.97%)
Mutual labels:  gzip, zip, decompression
Decompress
Extracting archives made easy
Stars: ✭ 316 (+117.93%)
Mutual labels:  extract, zip, tar
Mzip Android
An Android compress and extract library support popular compression format such as rar, zip
Stars: ✭ 95 (-34.48%)
Mutual labels:  extract, zip, archive
Swcompression
A Swift framework for working with compression, archives and containers.
Stars: ✭ 110 (-24.14%)
Mutual labels:  zip, tar, gzip
Grain
The Grain compiler toolchain and CLI. Home of the modern web staple. 🌾
Stars: ✭ 2,199 (+1416.55%)
Mutual labels:  webassembly, wasm
Skia Wasm Port
Port of the Skia drawing library to wasm, for use in javascript (node & browser)
Stars: ✭ 131 (-9.66%)
Mutual labels:  wasm, browser

Libarchivejs

npm version build status dependency status license

Overview

Libarchivejs is a archive tool for browser which can extract various types of compression, it's a port of libarchive to WebAssembly and javascript wrapper to make it easier to use. Since it runs on WebAssembly performance should be near native. Supported formats: ZIP, 7-Zip, RAR v4, RAR v5, TAR. Supported compression: GZIP, DEFLATE, BZIP2, LZMA

How to use

Install with npm i libarchive.js and use it as a ES module.

The library consists of two parts: ES module and webworker bundle, ES module part is your interface to talk to library, use it like any other module. The webworker bundle lives in the libarchive.js/dist folder so you need to make sure that it is available in your public folder since it will not get bundled if you're using bundler (it's all bundled up already) and specify correct path to Archive.init() method

import {Archive} from 'libarchive.js/main.js';

Archive.init({
    workerUrl: 'libarchive.js/dist/worker-bundle.js'
});

document.getElementById('file').addEventListener('change', async (e) => {
    const file = e.currentTarget.files[0];

    const archive = await Archive.open(file);
    let obj = await archive.extractFiles();
    
    console.log(obj);
});

// outputs
{
    ".gitignore": {File},
    "addon": {
        "addon.py": {File},
        "addon.xml": {File}
    },
    "README.md": {File}
}

More options

To get file listing without actually decompressing archive, use one of these methods

    await archive.getFilesObject();
    // outputs
    {
        ".gitignore": {CompressedFile},
        "addon": {
            "addon.py": {CompressedFile},
            "addon.xml": {CompressedFile}
        },
        "README.md": {CompressedFile}
    }

    await archive.getFilesArray();
    // outputs
    [
        {file: {CompressedFile}, path: ""},
        {file: {CompressedFile},   path: "addon/"},
        {file: {CompressedFile},  path: "addon/"},
        {file: {CompressedFile},  path: ""}
    ]

If these methods get called after archive.extractFiles(); they will contain actual files as well.

Decompression might take a while for larger files. To track each file as it gets extracted, archive.extractFiles accepts callback

    archive.extractFiles((entry) => { // { file: {File}, path: {String} }
        console.log(entry);
    });

Extract single file from archive

To extract a single file from the archive you can use the extract() method on the returned CompressedFile.

    const filesObj = await archive.getFilesObject();
    const file = await filesObj['.gitignore'].extract();

Check for encrypted data

    const archive = await Archive.open(file);
    await archive.hasEncryptedData();
    // true - yes
    // false - no
    // null - can not be determined

Extract encrypted archive

    const archive = await Archive.open(file);
    await archive.usePassword("password");
    let obj = await archive.extractFiles();

How it works

Libarchivejs is a port of the popular libarchive C library to WASM. Since WASM runs in the current thread, the library uses WebWorkers for heavy lifting. The ES Module (Archive class) is just a client for WebWorker. It's tiny and doesn't take up much space.

Only when you actually open archive file will the web worker be spawned and WASM module will be downloaded. Each Archive.open call corresponds to each WebWorker.

After calling an extractFiles worker, it will be terminated to free up memory. The client will still work with cached data.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].