https://github.com/borgar/zip
A library to manipulate zip files, using native implementations for compression where available.
https://github.com/borgar/zip
Last synced: about 1 month ago
JSON representation
A library to manipulate zip files, using native implementations for compression where available.
- Host: GitHub
- URL: https://github.com/borgar/zip
- Owner: borgar
- License: mit
- Created: 2026-05-04T11:35:20.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-05-04T11:45:54.000Z (3 months ago)
- Last Synced: 2026-05-04T13:34:04.447Z (3 months ago)
- Language: TypeScript
- Size: 21.2 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @borgar/zip
A library for reading and writing ZIP archives, using native platform APIs for compression where available.
- 🚀 Uses native platform implementations of zlib/deflate where available (which is nearly everywhere!),
only falling back to JS when all else fails.
- 🧠Keeps zip compressed in memory, rather than expanding all on load.
- 📦 Reads pretty much any zip file (only known limitation is Zip64 offsets that exceed the largest numbers JS can hold).
- 💬 Fully typed for your convenience.
## Installation
```bash
npm install @borgar/zip
```
## Usage
```js
import { ZipArchive } from '@borgar/zip';
// Read an existing archive
const zip = new ZipArchive(arrayBuffer);
const text = await zip.readText('hello.txt'); // "hello world\n"
const data = await zip.read('image.png'); // ArrayBuffer([ 89 50 4E 47 0D 0A 1A 0A... ])
// Create a new archive
const zip = new ZipArchive();
await zip.write('hello.txt', text);
await zip.write('data.bin', data);
const output = zip.toArrayBuffer();
// Trigger a browser download
const zipBlob = new Blob([ output ]);
const urlObject = URL.createObjectURL(zipBlob);
const a = document.createElement('a');
a.href = urlObject;
a.download = 'MyFilename.zip';
a.click();
URL.revokeObjectURL(urlObject);
```
## API
The API is fully documented in [API.md](API.md).