Skip to content

Commit

Permalink
Fix gzip streaming bug; add support for unzip filters
Browse files Browse the repository at this point in the history
  • Loading branch information
101arrowz committed Jun 15, 2021
1 parent 20795bc commit 688b524
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 40 deletions.
36 changes: 33 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
* [UnzipDecoder](interfaces/unzipdecoder.md)
* [UnzipDecoderConstructor](interfaces/unzipdecoderconstructor.md)
* [UnzipFile](interfaces/unzipfile.md)
* [UnzipFileInfo](interfaces/unzipfileinfo.md)
* [UnzipOptions](interfaces/unzipoptions.md)
* [Unzipped](interfaces/unzipped.md)
* [ZipAttributes](interfaces/zipattributes.md)
* [ZipInputFile](interfaces/zipinputfile.md)
Expand All @@ -62,6 +64,7 @@
* [FlateStreamHandler](README.md#flatestreamhandler)
* [StringStreamHandler](README.md#stringstreamhandler)
* [UnzipCallback](README.md#unzipcallback)
* [UnzipFileFilter](README.md#unzipfilefilter)
* [UnzipFileHandler](README.md#unzipfilehandler)
* [ZippableFile](README.md#zippablefile)

Expand Down Expand Up @@ -164,6 +167,18 @@ Callback for asynchronous ZIP decompression

___

### UnzipFileFilter

Ƭ **UnzipFileFilter**: (file: [UnzipFileInfo](interfaces/unzipfileinfo.md)) => boolean

A filter for files to be extracted during the unzipping process

**`param`** The info for the current file being processed

**`returns`** Whether or not to extract the current file

___

### UnzipFileHandler

Ƭ **UnzipFileHandler**: (file: [UnzipFile](interfaces/unzipfile.md)) => void
Expand Down Expand Up @@ -513,6 +528,20 @@ ___

### unzip

**unzip**(`data`: Uint8Array, `opts`: [AsyncUnzipOptions](interfaces/asyncunzipoptions.md), `cb`: [UnzipCallback](README.md#unzipcallback)): [AsyncTerminable](interfaces/asyncterminable.md)

Asynchronously decompresses a ZIP archive

#### Parameters:

Name | Type | Description |
------ | ------ | ------ |
`data` | Uint8Array | The raw compressed ZIP file |
`opts` | [AsyncUnzipOptions](interfaces/asyncunzipoptions.md) | The ZIP extraction options |
`cb` | [UnzipCallback](README.md#unzipcallback) | The callback to call with the decompressed files |

**Returns:** [AsyncTerminable](interfaces/asyncterminable.md)

**unzip**(`data`: Uint8Array, `cb`: [UnzipCallback](README.md#unzipcallback)): [AsyncTerminable](interfaces/asyncterminable.md)

Asynchronously decompresses a ZIP archive
Expand All @@ -530,7 +559,7 @@ ___

### unzipSync

**unzipSync**(`data`: Uint8Array): [Unzipped](interfaces/unzipped.md)
**unzipSync**(`data`: Uint8Array, `opts?`: [UnzipOptions](interfaces/unzipoptions.md)): [Unzipped](interfaces/unzipped.md)

Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
performance with more than one file.
Expand All @@ -540,6 +569,7 @@ performance with more than one file.
Name | Type | Description |
------ | ------ | ------ |
`data` | Uint8Array | The raw compressed ZIP file |
`opts?` | [UnzipOptions](interfaces/unzipoptions.md) | The ZIP extraction options |

**Returns:** [Unzipped](interfaces/unzipped.md)

Expand Down Expand Up @@ -675,7 +705,7 @@ ___

### zlibSync

**zlibSync**(`data`: Uint8Array, `opts`: [ZlibOptions](interfaces/zliboptions.md)): Uint8Array
**zlibSync**(`data`: Uint8Array, `opts?`: [ZlibOptions](interfaces/zliboptions.md)): Uint8Array

Compress data with Zlib

Expand All @@ -684,6 +714,6 @@ Compress data with Zlib
Name | Type | Description |
------ | ------ | ------ |
`data` | Uint8Array | The data to compress |
`opts` | [ZlibOptions](interfaces/zliboptions.md) | The compression options |
`opts?` | [ZlibOptions](interfaces/zliboptions.md) | The compression options |

**Returns:** Uint8Array
13 changes: 6 additions & 7 deletions docs/interfaces/asyncunzipoptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ Options for asynchronously expanding a ZIP archive

## Hierarchy

* AsyncOptions
* [UnzipOptions](unzipoptions.md)

**AsyncUnzipOptions**

## Index

### Properties

* [consume](asyncunzipoptions.md#consume)
* [filter](asyncunzipoptions.md#filter)

## Properties

### consume
### filter

`Optional` **consume**: boolean
`Optional` **filter**: [UnzipFileFilter](../README.md#unzipfilefilter)

*Inherited from [AsyncDeflateOptions](asyncdeflateoptions.md).[consume](asyncdeflateoptions.md#consume)*
*Inherited from [UnzipOptions](unzipoptions.md).[filter](unzipoptions.md#filter)*

Whether or not to "consume" the source data. This will make the typed array/buffer you pass in
unusable but will increase performance and reduce memory usage.
A filter function to extract only certain files from a ZIP archive
6 changes: 4 additions & 2 deletions docs/interfaces/unzipfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ ___

`Optional` **originalSize**: number

The original size of the file
The original size of the file. Will not be present for archives created
in a streaming fashion.

___

### size

`Optional` **size**: number

The compressed size of the file
The compressed size of the file. Will not be present for archives created
in a streaming fashion.

___

Expand Down
51 changes: 51 additions & 0 deletions docs/interfaces/unzipfileinfo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Interface: UnzipFileInfo

Information about a file to be extracted from a ZIP archive

## Hierarchy

* **UnzipFileInfo**

## Index

### Properties

* [compression](unzipfileinfo.md#compression)
* [name](unzipfileinfo.md#name)
* [originalSize](unzipfileinfo.md#originalsize)
* [size](unzipfileinfo.md#size)

## Properties

### compression

**compression**: number

The compression format for the data stream. This number is determined by
the spec in PKZIP's APPNOTE.txt, section 4.4.5. For example, 0 = no
compression, 8 = deflate, 14 = LZMA. If the filter function returns true
but this value is not 8, the unzip function will throw.

___

### name

**name**: string

The name of the file

___

### originalSize

**originalSize**: number

The original size of the file

___

### size

**size**: number

The compressed size of the file
23 changes: 23 additions & 0 deletions docs/interfaces/unzipoptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Interface: UnzipOptions

Options for expanding a ZIP archive

## Hierarchy

* **UnzipOptions**

[AsyncUnzipOptions](asyncunzipoptions.md)

## Index

### Properties

* [filter](unzipoptions.md#filter)

## Properties

### filter

`Optional` **filter**: [UnzipFileFilter](../README.md#unzipfilefilter)

A filter function to extract only certain files from a ZIP archive

0 comments on commit 688b524

Please sign in to comment.