# zipit

> Easily create zip archives

Latest version **2.0.0** (published 2019-07-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install zipit
pnpm add zipit
yarn add zipit
bun add zipit
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-07-20 |
| First published | 2016-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 2 |
| Unpacked size | 16.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Colin J. Ihrig |
| Maintainers | cjihrig |
| Keywords | zip |

## Links

- npm: https://www.npmjs.com/package/zipit
- Repository: https://github.com/cjihrig/zipit
- Issues: https://github.com/cjihrig/zipit/issues
- npm.io page: https://npm.io/package/zipit

## Dependencies (2)

- [yazl](https://npm.io/package/yazl.md) 2.5.1
- [insync](https://npm.io/package/insync.md) 2.1.1

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2019-07-20
- 1.0.2 — 2017-06-01
- 1.0.1 — 2016-07-09
- 1.0.0 — 2016-06-07

## README

# zipit

[![Current Version](https://img.shields.io/npm/v/zipit.svg)](https://www.npmjs.org/package/zipit)
[![Build Status via Travis CI](https://travis-ci.org/cjihrig/zipit.svg?branch=master)](https://travis-ci.org/cjihrig/zipit)
![Dependencies](http://img.shields.io/david/cjihrig/zipit.svg)
[![belly-button-style](https://img.shields.io/badge/eslint-bellybutton-4B32C3.svg)](https://github.com/cjihrig/belly-button)

`zipit` allows you to easily create zip archives from any combination of strings, `Buffer`s, files, directories, and other input types.

## Example

The following example creates a zip archive from a file, a directory, a Node.js `Buffer`, and a string.

```javascript
const Zipit = require('zipit');

Zipit({
  input: [
    './some_file.js',                                              // File
    './some_directory',                                            // Directory
    { name: 'some_buffer.buf', data: Buffer.from('foo-bar-baz') }, // Buffer
    { name: 'some_string.txt', data: 'blah-blah-blah' }            // String
  ],
  cwd: process.cwd()
}, (err, buffer) => {
  if (err) {
    console.error(err);
    return;
  }

  // Handle buffer, which is an instance of Buffer
});
```

## API

`zipit` exports a single function used to create zip archives.

  - Arguments
    - `options` (object) - An object that configures the creation of the zip archive. The following schema is supported.
      - `input` (string, object, or array) - If this is a string, it represents the path to a file or directory to include in the zip archive. If this is an object, it should have `name` and `data` properties which are used as the file name and contents in the zip archive. If this is an array, it should contain a combination of strings and objects as previously described.
      - `cwd` (string) - Specifies the working directory for relative file system operations. Defaults to `process.cwd()`.
    - `callback` (function) - A function which is called after the zip archive is created, or an error occurs. This function takes the following arguments.
      - `err` (error) - Represents any error that occurs.
      - `buffer` (`Buffer`) - Contains the zip archive, represented as a Node.js `Buffer`.
  - Returns
    - Nothing

---
_Source: https://npm.io/package/zipit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
