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

javascript-zip

v3.0.6

Published

Easily create Zips with the help of C++ in JavaScript

Downloads

74

Readme

npm version License: MIT

JavaScript-Zip

Currently Windows only.

Node.js tool to create ZIP files in JavaScript with native C++ speed using Miniz. License is MIT.


Install

npm install javascript-zip

Functions

zip(files: string[]): Buffer

builds a valid ZIP archive in memory from a list of file paths. It returns a Node Buffer with the ZIP bytes. It throws on missing files or I/O errors.

const fs = require('fs');
const { zip } = require('javascript-zip');

// Create a ZIP from FILES note.txt and image.png then stores the new ZIP as zipFile in memory to be used later.
const zipFile = zip([
  './note.txt',
  './image.png'
]);

// now zipped file is sitting in memory as 'zipFile'

// Writes the in-memory ZIP (zipFile) to disk as "bundle.zip"
fs.writeFileSync('bundle.zip', zipFile);

zipDisk(files: string[], outPath: string): void

creates a ZIP archive on disk from a list of file paths. It writes the archive to outPath and returns nothing. It throws on missing files or write errors. It is the disk variant of zip() and avoids holding the whole ZIP in memory.

const { zipDisk } = require('javascript-zip');

// 1st argument is an array of files. 2nd argument is the outpath. 
// This takes note.txt and image.png and writes them to a zip at "bundle.zip" in the same folder.
zipDisk(
  [
    './note.txt',
    './image.png'
  ],
  './bundle.zip'
);

zipDisk() is a faster way of writing the zip() example and avoid larger RAM usage. You would usually use zip() in cases when serving the ZIP or storing in a SQL or Redis.

unzip(zipBytes: Buffer): Record<string, Buffer>

reads a ZIP already in memory. Returns an object where each key is the path inside the ZIP and each value is a Node Buffer.

const fs = require('fs');
const { unzip } = require('javascript-zip');

// find our target zip file named 'bundle.zip'
const zipBytes = fs.readFileSync('./bundle.zip');

// zip is now in memory as 'files'
const files = unzip(zipBytes);

// 'files' is a list of key/value pairs of files paths/byte data.

// pull a specific file named 'note.txt'
if (files['note.txt']) {
  fs.writeFileSync('./unpackedNote.txt', files['note.txt']);
}

unzipDisk(zipBytes: Buffer, outDir: string): void

extracts all regular files from a ZIP in memory to outDir. Creates folders as needed.

This will pull the ZIP into memory THEN write it out to disk.

const fs = require('fs');
const path = require('path');
const { unzipDisk } = require('javascript-zip');

// THIS PULLS THE ZIP INTO MEMORY
const zipBytes = fs.readFileSync('./bundle.zip');

// creates our directory named 'out' where we will write out the ZIPs files to.
const outDir = path.resolve(__dirname, 'out');

unzipDisk(zipBytes, outDir);  // writes out/note.txt and out/image.png

Roadmap

  • Add Web assembly support.
  • Add ability to compress zips for server-client transfer and vice versa.