GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - magnetardev/archive: A port of libarchive to WebAssembly, with a simple JS wrapper.

BranchesTags
Open more actions menu

Latest commit

 

History

22 Commits
22 Commits

Folders and files

NameName
Last commit message
Last commit date
dist
dist
 
 
lib
lib
 
 
src
src
 
 
tests
tests
 
 
types
types
 
 
.gitignore
.gitignore
 
 
Dockerfile
Dockerfile
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
package.json
package.json
 
 
rollup.config.js
rollup.config.js
 
 
tsconfig.json
tsconfig.json
 
 
yarn.lock
yarn.lock
 
 

Repository files navigation

Archive

A port of libarchive to WebAssembly, with a simple JS wrapper.

It is highly recommended that you offload reading and writing to a Worker. For the browser or deno, that'd be through Worker and for node that would be through the worker_threads module. There isn't an official worker wrapper yet, but using a library like Comlink can get you up and running with one in minutes.

Install

# if you use yarn:
yarn add @magnetardev/archive

# if you use npm:
npm install @magnetardev/archive

Why?

Aren't there a few of these ports? Well, yes. In fact, this uses the exact same Dockerfile from libarchivejs. However, libarchivejs does not support Node and forces you to use a Worker. I also haven't found one that supports creating archives. Finally, the APIs most of the ports offer are not as simple as they can be, which is a shame. So, I made this.

Examples

Reading an archive

import * as archive from '@magnetardev/archive';

const buffer = ...; // Obtain a Uint8Array version of your archive.
const reader = await archive.createReader(buffer);
for (const entry of reader) {
  console.log(entry.path, entry.extract());
}
reader.close();

Creating an archive

import * as archive from "@magnetardev/archive";

// Create a writer.
const writer = await archive.createWriter();

// Add a file
const contents = new TextEncoder().encode("hello, world!");
writer.add("hello.txt", contents);

// Finalize the archive and get a Uint8Array version.
const zip = writer.close();
console.log(zip);

Building

Building is kind of a mess, but is quite easy with Docker. If you choose to do so without Docker, you need to compile OpenSSL, LZMA, and libarchive with emcc. This short guide covers the Docker build process:

  1. Run yarn build:wasm. This can take quite a while the first time, but consecutive builds will be much faster. This builds just the WebAssembly port and the Emscripten wrapper.
  2. Run yarn build. This builds the JS wrapper.
  3. Done.

About

A port of libarchive to WebAssembly, with a simple JS wrapper.

Topics

7zipcompressiondecompressionjavascriptlibarchivetypescriptwebassemblyzip

Resources

Readme
Activity

Stars

9 stars

Watchers

3 watching

Forks

0 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.