Skip to content

Commit

Permalink
Update docs for gunzip
Browse files Browse the repository at this point in the history
  • Loading branch information
codedread committed Feb 5, 2024
1 parent 5facf91 commit 440478c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ A set of dependency-free JavaScript modules to work with binary data in JS (usin
[Typed Arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)).
Includes:

* bitjs/archive: Decompressing files (unzip, unrar, untar) in JavaScript, implemented as Web
Workers where supported, and allowing progressive unarchiving while streaming.
* bitjs/archive: Decompressing files (unzip, unrar, untar, gunzip) in JavaScript, implemented as
Web Workers where supported, and allowing progressive unarchiving while streaming.
* bitjs/codecs: Get the codec info of media containers in a ISO RFC6381 MIME type string.
* bitjs/file: Detect the type of file from its binary signature.
* bitjs/image: Parsing GIF, JPEG, PNG. Conversion of WebP to PNG or JPEG.
Expand Down Expand Up @@ -49,7 +49,7 @@ const { getFullMIMEString } = await import('@codedread/bitjs');
### bitjs.archive

This package includes objects for decompressing and compressing binary data in popular archive
formats (zip, rar, tar). Here is a simple example of unrar:
formats (zip, rar, tar, gzip). Here is a simple example of unrar:

#### Decompressing

Expand Down
21 changes: 11 additions & 10 deletions docs/bitjs.archive.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# bitjs.archive

This package includes objects for unarchiving binary data in popular archive formats (zip, rar, tar)
providing unzip, unrar and untar capabilities via JavaScript in the browser or various JavaScript
runtimes (node, deno, bun).
This package includes objects for unarchiving binary data in popular archive formats (zip, rar,
tar, gzip) providing unzip, unrar, untar, gunzip capabilities via JavaScript in the browser or
various JavaScript runtimes (node, deno, bun).

A prototype version of a compressor that creates Zip files is also present.
A compressor that creates Zip files is also present.

The decompression / compression happens inside a Web Worker, if the runtime supports it (browsers,
deno). The library uses native decompression, if supported by the browser
(via [DecompressionStream](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream/DecompressionStream)), and falls back to JavaScript implementations otherwise.
(via [DecompressionStream](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream/DecompressionStream)),
and falls back to JavaScript implementations otherwise.

The API is event-based, you will want to subscribe to some of these events:
* 'progress': Periodic updates on the progress (bytes processed).
Expand All @@ -31,7 +32,7 @@ etc.
```javascript
import { Unzipper } from './bitjs/archive/decompress.js';
const unzipper = new Unzipper(zipFileArrayBuffer);
unzipper.addEventListener('extract', (evt) => {
unzipper.onExtract(evt => {
const {filename, fileData} = evt.unarchivedFile;
console.log(`unzipped ${filename} (${fileData.byteLength} bytes)`);
// Do something with fileData...
Expand All @@ -40,7 +41,7 @@ etc.
unzipper.start();
```

`start()` is an async method that resolves a `Promise` when the unzipping is complete, so you can
`start()` is an async method that resolves a `Promise` when the decompression is complete, so you can
`await` on it, if you need to.

### Progressive unzipping
Expand All @@ -65,14 +66,14 @@ constructor, and send subsequent `ArrayBuffers` using the `update()` method.

### getUnarchiver()

If you don't want to bother with figuring out if you have a zip, rar, or tar file, you can use the
convenience method `getUnarchiver()`, which sniffs the bytes for you and creates the appropriate
If you don't want to bother with figuring out if you have a zip, rar, tar, or gz file, you can use
the convenience method `getUnarchiver()`, which sniffs the bytes for you and creates the appropriate
unarchiver.

```javascript
import { getUnarchiver } from './bitjs/archive/decompress.js';
const unarchiver = getUnarchiver(anArrayBuffer);
unarchive.addEventListener('extract', () => {...});
unarchiver.onExtract(evt => {...});
// etc...
unarchiver.start();
```
Expand Down

0 comments on commit 440478c

Please sign in to comment.