Skip to content

Commit ad6e684

Browse files
committed
Fix errors
1 parent 3a55375 commit ad6e684

File tree

6 files changed

+281
-104
lines changed

6 files changed

+281
-104
lines changed

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.7.0
2+
- Improved errors
3+
- Now errors are error objects instead of strings
4+
- Check the error code to apply custom logic based on error type
5+
- Made async operations always call callbacks asynchronously
6+
- Fixed bug that caused errors to not appear in asynchronous operations in browsers
17
## 0.6.10
28
- Fixed async operations on Node.js with native ESM
39
## 0.6.5

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ See the [documentation](https://github.com/101arrowz/fflate/blob/master/docs/REA
485485

486486
## Bundle size estimates
487487

488-
Since `fflate` uses ES Modules, this table should give you a general idea of `fflate`'s bundle size for the features you need. The maximum bundle size that is possible with `fflate` is about 27kB if you use every single feature, but feature parity with `pako` is only around 10kB (as opposed to 45kB from `pako`). If your bundle size increases dramatically after adding `fflate`, please [create an issue](https://github.com/101arrowz/fflate/issues/new).
488+
Since `fflate` uses ES Modules, this table should give you a general idea of `fflate`'s bundle size for the features you need. The maximum bundle size that is possible with `fflate` is about 30kB if you use every single feature, but feature parity with `pako` is only around 10kB (as opposed to 45kB from `pako`). If your bundle size increases dramatically after adding `fflate`, please [create an issue](https://github.com/101arrowz/fflate/issues/new).
489489

490490
| Feature | Bundle size (minified) | Nearest competitor |
491491
|-------------------------|--------------------------------|------------------------|

‎docs/README.md‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* [AsyncZippable](interfaces/asynczippable.md)
4343
* [AsyncZlibOptions](interfaces/asynczliboptions.md)
4444
* [DeflateOptions](interfaces/deflateoptions.md)
45+
* [FlateError](interfaces/flateerror.md)
4546
* [GzipOptions](interfaces/gzipoptions.md)
4647
* [UnzipDecoder](interfaces/unzipdecoder.md)
4748
* [UnzipDecoderConstructor](interfaces/unzipdecoderconstructor.md)
@@ -64,6 +65,10 @@
6465
* [UnzipFileHandler](README.md#unzipfilehandler)
6566
* [ZippableFile](README.md#zippablefile)
6667

68+
### Variables
69+
70+
* [FlateErrorCode](README.md#flateerrorcode)
71+
6772
### Functions
6873

6974
* [decompress](README.md#decompress)
@@ -91,7 +96,7 @@
9196

9297
### AsyncFlateStreamHandler
9398

94-
Ƭ **AsyncFlateStreamHandler**: (err: Error,data: Uint8Array,final: boolean) => void
99+
Ƭ **AsyncFlateStreamHandler**: (err: [Error](interfaces/flateerror.md#error),data: Uint8Array,final: boolean) => void
95100

96101
Handler for asynchronous data (de)compression streams
97102

@@ -113,7 +118,7 @@ ___
113118

114119
### FlateCallback
115120

116-
Ƭ **FlateCallback**: (err: Error \| string,data: Uint8Array) => void
121+
Ƭ **FlateCallback**: (err: [Error](interfaces/flateerror.md#error) \| string,data: Uint8Array) => void
117122

118123
Callback for asynchronous (de)compression methods
119124

@@ -149,7 +154,7 @@ ___
149154

150155
### UnzipCallback
151156

152-
Ƭ **UnzipCallback**: (err: Error \| string,data: [Unzipped](interfaces/unzipped.md)) => void
157+
Ƭ **UnzipCallback**: (err: [Error](interfaces/flateerror.md#error) \| string,data: [Unzipped](interfaces/unzipped.md)) => void
153158

154159
Callback for asynchronous ZIP decompression
155160

@@ -175,6 +180,34 @@ ___
175180

176181
A file that can be used to create a ZIP archive
177182

183+
## Variables
184+
185+
### FlateErrorCode
186+
187+
`Const` **FlateErrorCode**: object = { UnexpectedEOF: 0, InvalidBlockType: 1, InvalidLengthLiteral: 2, InvalidDistance: 3, StreamFinished: 4, NoStreamHandler: 5, InvalidHeader: 6, NoCallback: 7, InvalidUTF8: 8, ExtraFieldTooLong: 9, InvalidDate: 10, FilenameTooLong: 11, StreamFinishing: 12, InvalidZipData: 13, UnknownCompressionMethod: 14} as const
188+
189+
Codes for errors generated within this library
190+
191+
#### Type declaration:
192+
193+
Name | Type |
194+
------ | ------ |
195+
`ExtraFieldTooLong` | 9 |
196+
`FilenameTooLong` | 11 |
197+
`InvalidBlockType` | 1 |
198+
`InvalidDate` | 10 |
199+
`InvalidDistance` | 3 |
200+
`InvalidHeader` | 6 |
201+
`InvalidLengthLiteral` | 2 |
202+
`InvalidUTF8` | 8 |
203+
`InvalidZipData` | 13 |
204+
`NoCallback` | 7 |
205+
`NoStreamHandler` | 5 |
206+
`StreamFinished` | 4 |
207+
`StreamFinishing` | 12 |
208+
`UnexpectedEOF` | 0 |
209+
`UnknownCompressionMethod` | 14 |
210+
178211
## Functions
179212

180213
### decompress

‎docs/interfaces/flateerror.md‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Interface: FlateError
2+
3+
An error generated within this library
4+
5+
## Hierarchy
6+
7+
* [Error](flateerror.md#error)
8+
9+
**FlateError**
10+
11+
## Index
12+
13+
### Properties
14+
15+
* [Error](flateerror.md#error)
16+
* [code](flateerror.md#code)
17+
* [message](flateerror.md#message)
18+
* [name](flateerror.md#name)
19+
* [stack](flateerror.md#stack)
20+
21+
## Properties
22+
23+
### Error
24+
25+
**Error**: ErrorConstructor
26+
27+
___
28+
29+
### code
30+
31+
**code**: number
32+
33+
The code associated with this error
34+
35+
___
36+
37+
### message
38+
39+
**message**: string
40+
41+
*Inherited from [FlateError](flateerror.md).[message](flateerror.md#message)*
42+
43+
___
44+
45+
### name
46+
47+
**name**: string
48+
49+
*Inherited from [FlateError](flateerror.md).[name](flateerror.md#name)*
50+
51+
___
52+
53+
### stack
54+
55+
`Optional` **stack**: string
56+
57+
*Inherited from [FlateError](flateerror.md).[stack](flateerror.md#stack)*

0 commit comments

Comments
 (0)