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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@holmlibs/unzip

v1.0.0

Published

A fast and efficient ZIP file extraction library for Bun

Downloads

215

Readme

@holmlibs/unzip

A fast and efficient ZIP file extraction library for Bun. This library provides a simple API for reading and extracting ZIP files with support for both single-file and batch extraction operations.

Features

  • 🚀 Fast ZIP file extraction
  • 📦 Support for both single-file and batch extraction
  • 📊 Progress tracking for extraction operations
  • 🔄 Concurrent file extraction with customizable limits
  • 💡 Simple and intuitive API

Installation

bun add @holmlibs/unzip

Usage

Basic Example

import { createZipReader } from '@holmlibs/unzip';

// Create a ZIP reader
const reader = createZipReader('path/to/archive.zip');

// Extract all files
await reader.extractAll('output/directory', (current, total) => {
  console.log(`Progress: ${current}/${total} files`);
});

// Extract a single file
const entry = reader.getEntry('example.txt');
if (entry) {
  // Get file content as text
  const text = await entry.getText();
  console.log(text);

  // Or extract to a specific location
  await entry.extractTo('output/directory');
}

High-Level API Examples

The high-level API provides a convenient interface using createZipReader.

Extract All Files

await createZipReader('test.zip').extractAll('test');

Extracts all files from 'test.zip' to the 'test' directory.

Extract Single File

await createZipReader('test.zip').getEntry('example.txt')?.extractTo('test');

Extracts only 'example.txt' from the ZIP file to the 'test' directory.

List All Entries

createzipReader('test.zip').getEntries();

Returns a Map containing all entries in the ZIP file.

Get File Buffer

await createZipReader('test.zip').getEntry('example.txt')?.getBuffer();

Returns the raw buffer content of 'example.txt'.

Get File Text

await createZipReader('test.zip').getEntry('example.txt')?.getText();

Returns the text content of 'example.txt' (assumes UTF-8 encoding).

Low-Level API Examples

The low-level API provides more control over the extraction process.

List Entry Details

const buffer = readFileSync('test.zip');
const entries = getEntries(buffer);
entries.forEach((entry) => {
    console.log('Entry name', entry[0]); 
    console.log('Compression method', entry[1]);
    console.log('Position data', entry[2]);
});

Lists detailed information about each entry in the ZIP file.

Extract All Files (Low-Level)

const buffer = readFileSync('test.zip');
const entries = getEntries(buffer);
await extractAll(buffer, entries, 'test');

Extracts all files using the low-level API.

Extract Single File (Low-Level)

const buffer = readFileSync('test.zip');
const entries = getEntries(buffer);
const entry = entries.get('example.txt');
if(entry)
    await extractEntry(buffer, entry, 'test');

Extracts a single file using the low-level API.

Manual Decompression

const buffer = readFileSync('test.zip');
const entries = getEntries(buffer);
const entry = entries.get('example.txt');
if(entry){
    const decompressed = await decompressEntry(buffer, entry);
    await writeFile(join('test', entry[0]), decompressed);
}

Manually decompresses and writes a file using the lowest-level API functions.

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.