@@ -167,6 +167,45 @@ declare namespace JSZip {
167
167
}
168
168
}
169
169
170
+ declare namespace StreamHelper {
171
+ type DataEventCallback = ( dataChunk : any , metadata : any ) => any
172
+ type EndEventCallback = ( ) => any
173
+ type ErrorEventCallback = ( error : Error ) => any
174
+
175
+ interface StreamHelper {
176
+ /**
177
+ * Register a listener on an event
178
+ *
179
+ * @param event The name of the event. Only 3 events are supported : data, end and error
180
+ * @param callback The function called when the event occurs
181
+ * @return The current StreamHelper object, for chaining
182
+ */
183
+ on ( event : 'data' | 'end' | 'error' , callback : DataEventCallback | EndEventCallback | ErrorEventCallback ) ;
184
+
185
+ /**
186
+ * Read the whole stream and call a callback with the complete content
187
+ *
188
+ * @param updateCallback The function called every time the stream updates
189
+ * @return A Promise of the full content
190
+ */
191
+ accumulate ( updateCallback ?: ( metadata : any ) => any ) : Promise < any > ;
192
+
193
+ /**
194
+ * Resume the stream if the stream is paused. Once resumed, the stream starts sending data events again
195
+ *
196
+ * @return The current StreamHelper object, for chaining
197
+ */
198
+ resume ( ) : StreamHelper ;
199
+
200
+ /**
201
+ * Pause the stream if the stream is running. Once paused, the stream stops sending data events
202
+ *
203
+ * @return The current StreamHelper object, for chaining
204
+ */
205
+ pause ( ) : StreamHelper ;
206
+ }
207
+ }
208
+
170
209
interface JSZip {
171
210
files : { [ key : string ] : JSZip . JSZipObject } ;
172
211
@@ -254,6 +293,14 @@ interface JSZip {
254
293
*/
255
294
generateNodeStream ( options ?: JSZip . JSZipGeneratorOptions < 'nodebuffer' > , onUpdate ?: OnUpdateCallback ) : NodeJS . ReadableStream ;
256
295
296
+ /**
297
+ * Generates the complete zip file with the internal stream implementation
298
+ *
299
+ * @param options Optional options for the generator
300
+ * @return a StreamHelper
301
+ */
302
+ generateInternalStream ( options ?: JSZip . JSZipGeneratorOptions ) : StreamHelper . StreamHelper
303
+
257
304
/**
258
305
* Deserialize zip file asynchronously
259
306
*
0 commit comments