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

zip-up

v1.1.0

Published

Create .zip files from directories or files

Downloads

1,090

Readme

zip-up

Simple zip module for Node.js

NOTE: This module uses async/await; must use Node v7.6.0 or higher.

Introduction

I created this project because there isn't a simple, easy to use zip reader for NodeJS which has few dependencies and simple in implementation. When searching for such a project, I came across this one:

https://www.npmjs.com/package/node-stream-zip

However, it is no longer supported, and the tip is broken. I wanted to be able to use Node's built in zlib support, and the author had already done the legwork. He also had code which output correct zip headers. All I had to do is make sure the file itself streams properly to the output file in question using Node streams. I hope it proves as useful to you as it did to me!

What was needed was the ability to add multiple files and directories into a single zip file without having to have a staging folder on the harddrive. Yes, this means everything is done in memory, so be mindful of file sizes and the available RAM on the target machine.

Installation

$ npm install zip-up

Usage

import Zip from 'zip-up'
const zipper = new Zip('output.zip', { level: 1 })
await zipper.addDir('directory/to/zip')
await zipper.addDir('other/directory/to/zip')
const bytesWritten = await zipper.finalize()
// bytesWritten -> 276

Options

Options can be passed as the second argument to Zip.addDir():

await zipper.addDir('directory', {
  ignoreHidden: true,
  exclude: ['/tmp/']
})

ignoreHidden: whether to ignore hidden files; i.e. files beginning with . (default: false).

exclude: array of paths to exclude (default: []) Note: this applies to files as well as directories.

Testing

Run npm test to run the test suite. The tests insure that no errors occur and also verifies that the file is created correctly by unzipping and examining the file contents.

Contributing

When submitting a PR for review, make sure that you include a test for your proposed feature or fix.