forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jszip.d.ts
191 lines (169 loc) · 4.68 KB
/
jszip.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// Type definitions for JSZip
// Project: http://stuk.github.com/jszip/
// Definitions by: mzeiher <https://github.com/mzeiher>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface JSZip {
/**
* Get a file from the archive
*
* @param Path relative path to file
* @return File matching path, null if no file found
*/
file(path: string): JSZipObject;
/**
* Get files matching a RegExp from archive
*
* @param path RegExp to match
* @return Return all matching files or an empty array
*/
file(path: RegExp): JSZipObject[];
/**
* Add a file to the archive
*
* @param path Relative path to file
* @param content Content of the file
* @param options Optional information about the file
* @return JSZip object
*/
file(path: string, data: any, options?: JSZipFileOptions): JSZip;
/**
* Return an new JSZip instance with the given folder as root
*
* @param name Name of the folder
* @return New JSZip object with the given folder as root or null
*/
folder(name: string): JSZip;
/**
* Returns new JSZip instances with the matching folders as root
*
* @param name RegExp to match
* @return New array of JSZipFile objects which match the RegExp
*/
folder(name: RegExp): JSZipObject[];
/**
* Get all files wchich match the given filter function
*
* @param predicate Filter function
* @return Array of matched elements
*/
filter(predicate: (relativePath: string, file: JSZipObject) => boolean): JSZipObject[];
/**
* Removes the file or folder from the archive
*
* @param path Relative path of file or folder
* @return Returns the JSZip instance
*/
remove(path: string): JSZip;
/**
* Generates a new archive
*
* @param options Optional options for the generator
* @return The serialized archive
*/
generate(options?: JSZipGeneratorOptions): any;
/**
* Deserialize zip file
*
* @param data Serialized zip file
* @param options Options for deserializing
* @return Returns the JSZip instance
*/
load(data: any, options: JSZipLoadOptions): JSZip;
}
interface JSZipObject {
name: string;
dir: boolean;
date: Date;
comment: string;
options: JSZipObjectOptions;
asText(): string;
asBinary(): string;
asArrayBuffer(): ArrayBuffer;
asUint8Array(): Uint8Array;
//asNodeBuffer(): Buffer;
}
interface JSZipFileOptions {
base64?: boolean;
binary?: boolean;
date?: Date;
compression?: string;
comment?: string;
optimizedBinaryString?: boolean;
createFolders?: boolean;
}
interface JSZipObjectOptions {
/** deprecated */
base64: boolean;
/** deprecated */
binary: boolean;
/** deprecated */
dir: boolean;
/** deprecated */
date: Date;
compression: string;
}
interface JSZipGeneratorOptions {
/** deprecated */
base64?: boolean;
/** DEFLATE or STORE */
compression?: string;
/** base64 (default), string, uint8array, blob */
type?: string;
comment?: string;
}
interface JSZipLoadOptions {
base64?: boolean;
checkCRC32?: boolean;
optimizedBinaryString?: boolean;
createFolders?: boolean;
}
interface JSZipSupport {
arraybuffer: boolean;
uint8array: boolean;
blob: boolean;
nodebuffer: boolean;
}
interface DEFLATE {
/** pako.deflateRaw, level:0-9 */
compress(input: string, compressionOptions: {level:number}): Uint8Array;
compress(input: number[], compressionOptions: {level:number}): Uint8Array;
compress(input: Uint8Array, compressionOptions: {level:number}): Uint8Array;
/** pako.inflateRaw */
uncompress(input: string): Uint8Array;
uncompress(input: number[]): Uint8Array;
uncompress(input: Uint8Array): Uint8Array;
}
declare var JSZip: {
/**
* Create JSZip instance
*/
(): JSZip;
/**
* Create JSZip instance
* If no parameters given an empty zip archive will be created
*
* @param data Serialized zip archive
* @param options Description of the serialized zip archive
*/
(data: any, options?: JSZipLoadOptions): JSZip;
/**
* Create JSZip instance
*/
new (): JSZip;
/**
* Create JSZip instance
* If no parameters given an empty zip archive will be created
*
* @param data Serialized zip archive
* @param options Description of the serialized zip archive
*/
new (data: any, options?: JSZipLoadOptions): JSZip;
prototype: JSZip;
support: JSZipSupport;
compressions: {
DEFLATE: DEFLATE;
}
}
declare module "jszip" {
export = JSZip;
}