npm.io
0.1.1 • Published 3 years ago

@buh/unzip

Licence
MIT
Version
0.1.1
Deps
0
Size
12 kB
Vulns
0
Weekly
0
Stars
1

unzip

Installation

npm install @buh/unzip

Quick Examples

Bun

Use inflateSync from Bun.inflateSync

import { Zip } from '@buh/unzip';

const file = Bun.file('archive.zip');
const arrayBuffer = await file.arrayBuffer();

const zip = await Zip.create(arrayBuffer);
for (const entry of zip.iterator()) {
  console.log(entry.fileName, entry.lastModified(), zip.textDecoder.decode(entry.getData()));
}
Node

Use inflateRawSync from node:zlib

import { Zip } from '@buh/unzip';
import { readFileSync } from 'node:fs';

const file = readFileSync('archive.zip');

const zip = await Zip.create(file.buffer);
for (const entry of zip.iterator()) {
  console.log(entry.fileName, entry.lastModified(), zip.textDecoder.decode(entry.getData()));
}

References

Chagelogs

You can track the changelogs in CHANGELOGS.md file.

Keywords