npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@magnetardev/archive

v1.0.5

Published

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

Downloads

22

Readme

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.