zip-writer 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -132
- package/dist/index.d.ts +30 -57
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +141 -131
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +20 -0
- package/dist/utils.js.map +1 -1
- package/dist/write-central-directory.d.ts +2 -2
- package/dist/write-central-directory.d.ts.map +1 -1
- package/dist/write-central-directory.js +5 -9
- package/dist/write-central-directory.js.map +1 -1
- package/dist/write-entry.d.ts +2 -17
- package/dist/write-entry.d.ts.map +1 -1
- package/dist/write-entry.js +4 -95
- package/dist/write-entry.js.map +1 -1
- package/package.json +28 -7
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# zip-writable
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/zip-writer)
|
|
4
|
+
[](https://github.com/gmaclennan/zip-writer/actions/workflows/test.yml)
|
|
5
|
+
[](https://bundlejs.com/?q=zip-writer%401.1.2&treeshake=%5B*%5D)
|
|
6
|
+
|
|
3
7
|
A modern streaming ZIP archive writer for JavaScript that uses the
|
|
4
8
|
[Web Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
|
|
5
9
|
and
|
|
@@ -7,12 +11,17 @@ and
|
|
|
7
11
|
|
|
8
12
|
## Features
|
|
9
13
|
|
|
10
|
-
- **Streaming API** - Write ZIP archives
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
- **Streaming API** - Write ZIP archives without buffering entries our the
|
|
15
|
+
output zip into memory
|
|
16
|
+
- **Browser & Node.js** - Works in both environments with the same API
|
|
17
|
+
- **Small bundle size** - ~3KB minified and gzipped
|
|
18
|
+
- **Minimal dependencies** - Only depends on
|
|
19
|
+
[p-mutex](https://www.npmjs.com/package/p-mutex) for mutex locking (adds ~390
|
|
20
|
+
bytes)
|
|
13
21
|
- **ZIP64 support** - Automatic handling of large files and archives
|
|
14
|
-
- **
|
|
15
|
-
|
|
22
|
+
- **Editable Central Directory** - Reorder, rename, or remove entries before
|
|
23
|
+
finalizing
|
|
24
|
+
- **100% test coverage** - Output validated against standard ZIP tools
|
|
16
25
|
|
|
17
26
|
## Installation
|
|
18
27
|
|
|
@@ -31,13 +40,16 @@ const zipWriter = new ZipWriter();
|
|
|
31
40
|
zipWriter.readable.pipeTo(writableStream);
|
|
32
41
|
|
|
33
42
|
// Add entries to the ZIP
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
const data = new TextEncoder().encode("Hello, World!");
|
|
44
|
+
const info = await zipWriter.addEntry({
|
|
45
|
+
readable: new ReadableStream({
|
|
46
|
+
start(controller) {
|
|
47
|
+
controller.enqueue(data);
|
|
48
|
+
controller.close();
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
name: "hello.txt",
|
|
52
|
+
});
|
|
41
53
|
console.log(info);
|
|
42
54
|
|
|
43
55
|
// Finalize the ZIP archive
|
|
@@ -83,93 +95,66 @@ return new Response(zipWriter.readable, {
|
|
|
83
95
|
});
|
|
84
96
|
```
|
|
85
97
|
|
|
86
|
-
##### `entries:
|
|
98
|
+
##### `entries(): Promise<EntryInfo[]>`
|
|
87
99
|
|
|
88
|
-
|
|
89
|
-
metadata like size, CRC32,
|
|
100
|
+
Returns a promise that resolves to an array of all entries that have been
|
|
101
|
+
written to the archive. Each entry contains metadata like size, CRC32,
|
|
102
|
+
compression info, etc.
|
|
90
103
|
|
|
91
104
|
#### Methods
|
|
92
105
|
|
|
93
|
-
##### `
|
|
94
|
-
|
|
95
|
-
Convenience method to add a buffer as an entry to the zip archive. Returns a
|
|
96
|
-
promise that resolves to the entry info once written. For more efficient
|
|
97
|
-
streaming writes, use `createEntryStream()`.
|
|
98
|
-
|
|
99
|
-
**Parameters:**
|
|
100
|
-
|
|
101
|
-
- `data: Uint8Array` - Entry data to write
|
|
102
|
-
- `options.name: string` - Entry name including internal path (required)
|
|
103
|
-
- `options.comment?: string` - Entry comment
|
|
104
|
-
- `options.date?: Date` - Entry date (defaults to current date)
|
|
105
|
-
- `options.mode?: number` - Entry permissions (Unix-style mode)
|
|
106
|
-
- `options.store?: boolean` - Set to `true` to disable compression (defaults to
|
|
107
|
-
`false`, using DEFLATE compression)
|
|
108
|
-
|
|
109
|
-
**Example:**
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
const data = new TextEncoder().encode("Hello, World!");
|
|
113
|
-
const entryInfo = await zipWriter.createEntry(data, { name: "hello.txt" });
|
|
114
|
-
console.log(entryInfo);
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
##### `createEntryStream(options: EntryOptions): EntryWriter`
|
|
106
|
+
##### `addEntry(entry: Entry): Promise<EntryInfo>`
|
|
118
107
|
|
|
119
|
-
|
|
120
|
-
|
|
108
|
+
Add an entry to the ZIP archive. Returns a promise that resolves to the entry
|
|
109
|
+
info once written.
|
|
121
110
|
|
|
122
111
|
**Parameters:**
|
|
123
112
|
|
|
124
|
-
- `
|
|
125
|
-
|
|
126
|
-
- `
|
|
127
|
-
- `
|
|
128
|
-
- `
|
|
113
|
+
- `entry.readable: ReadableStream<ArrayBufferView>` - Readable stream of entry
|
|
114
|
+
data
|
|
115
|
+
- `entry.name: string` - Entry name including internal path (required)
|
|
116
|
+
- `entry.comment?: string` - Entry comment
|
|
117
|
+
- `entry.date?: Date` - Entry date (defaults to current date)
|
|
118
|
+
- `entry.mode?: number` - Entry permissions (Unix-style mode)
|
|
119
|
+
- `entry.store?: boolean` - Set to `true` to disable compression (defaults to
|
|
129
120
|
`false`, using DEFLATE compression)
|
|
130
121
|
|
|
131
122
|
**Examples:**
|
|
132
123
|
|
|
133
124
|
```ts
|
|
134
|
-
//
|
|
135
|
-
const entry = zipWriter.createEntryStream({ name: "readme.txt" });
|
|
136
|
-
const writer = entry.writable.getWriter();
|
|
137
|
-
await writer.write(new TextEncoder().encode("Hello!"));
|
|
138
|
-
await writer.close();
|
|
139
|
-
|
|
140
|
-
// Stream a fetch response
|
|
125
|
+
// Stream from a fetch response
|
|
141
126
|
const response = await fetch(imageUrl);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
127
|
+
await zipWriter.addEntry({
|
|
128
|
+
readable: response.body,
|
|
129
|
+
name: "images/photo.jpg",
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Stream from a Uint8Array
|
|
133
|
+
const data = new TextEncoder().encode("Hello, World!");
|
|
134
|
+
await zipWriter.addEntry({
|
|
135
|
+
readable: new ReadableStream({
|
|
136
|
+
start(controller) {
|
|
137
|
+
controller.enqueue(data);
|
|
138
|
+
controller.close();
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
name: "hello.txt",
|
|
142
|
+
});
|
|
145
143
|
|
|
146
144
|
// With custom date and permissions
|
|
147
|
-
zipWriter.
|
|
145
|
+
await zipWriter.addEntry({
|
|
146
|
+
readable: scriptStream,
|
|
148
147
|
name: "script.sh",
|
|
149
148
|
date: new Date("2024-01-01"),
|
|
150
149
|
mode: 0o755, // executable
|
|
151
|
-
})
|
|
150
|
+
});
|
|
152
151
|
|
|
153
152
|
// Disable compression for already-compressed files
|
|
154
|
-
zipWriter.
|
|
153
|
+
await zipWriter.addEntry({
|
|
154
|
+
readable: videoStream,
|
|
155
155
|
name: "video.mp4",
|
|
156
156
|
store: true, // no compression
|
|
157
|
-
})
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
##### `onceQueueEmpty(): Promise<void>`
|
|
161
|
-
|
|
162
|
-
Wait until all currently queued entries have been written. Useful when you need
|
|
163
|
-
to ensure entries are complete before continuing.
|
|
164
|
-
|
|
165
|
-
```ts
|
|
166
|
-
// Add multiple entries
|
|
167
|
-
zipWriter.createEntryStream({ name: "file1.txt" }).writable;
|
|
168
|
-
zipWriter.createEntryStream({ name: "file2.txt" }).writable;
|
|
169
|
-
|
|
170
|
-
// Wait for all to complete
|
|
171
|
-
await zipWriter.onceQueueEmpty();
|
|
172
|
-
console.log(`Wrote ${zipWriter.entries.length} entries`);
|
|
157
|
+
});
|
|
173
158
|
```
|
|
174
159
|
|
|
175
160
|
##### `finalize(options?): Promise<{ zip64: boolean, uncompressedEntriesSize: bigint, compressedEntriesSize: bigint, fileSize: bigint }>`
|
|
@@ -205,11 +190,8 @@ console.log(
|
|
|
205
190
|
**Example with entries option:**
|
|
206
191
|
|
|
207
192
|
```ts
|
|
208
|
-
// Wait for all entries to be written
|
|
209
|
-
await zipWriter.onceQueueEmpty();
|
|
210
|
-
|
|
211
193
|
// Get current entries and modify them
|
|
212
|
-
const entries =
|
|
194
|
+
const entries = await zipWriter.entries();
|
|
213
195
|
|
|
214
196
|
// Remove an entry
|
|
215
197
|
const filtered = entries.filter((e) => e.name !== "temp.txt");
|
|
@@ -227,37 +209,11 @@ const sorted = [...entries].sort((a, b) => a.name.localeCompare(b.name));
|
|
|
227
209
|
await zipWriter.finalize({ entries: sorted });
|
|
228
210
|
```
|
|
229
211
|
|
|
230
|
-
### `
|
|
231
|
-
|
|
232
|
-
Returned by `ZipWriter.createEntryStream()`. Provides a writable stream to write
|
|
233
|
-
entry data.
|
|
212
|
+
### `EntryInfo`
|
|
234
213
|
|
|
235
|
-
|
|
214
|
+
Returned by `ZipWriter.addEntry()`. Contains metadata about a written entry.
|
|
236
215
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
The writable stream to write entry data to. Close this stream when done writing.
|
|
240
|
-
|
|
241
|
-
```ts
|
|
242
|
-
const entryWriter = zipWriter.createEntryStream({ name: "data.txt" });
|
|
243
|
-
|
|
244
|
-
// Using a writer
|
|
245
|
-
const writer = entryWriter.writable.getWriter();
|
|
246
|
-
await writer.write(new TextEncoder().encode("chunk 1"));
|
|
247
|
-
await writer.write(new TextEncoder().encode("chunk 2"));
|
|
248
|
-
await writer.close();
|
|
249
|
-
|
|
250
|
-
// Using pipeTo
|
|
251
|
-
someReadableStream.pipeTo(entryWriter.writable);
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
#### Methods
|
|
255
|
-
|
|
256
|
-
##### `getEntryInfo(): Promise<EntryInfo>`
|
|
257
|
-
|
|
258
|
-
Get entry info. Resolves once all data has been written to the ZIP stream.
|
|
259
|
-
|
|
260
|
-
**Returns `EntryInfo`:**
|
|
216
|
+
**Properties:**
|
|
261
217
|
|
|
262
218
|
- `name: string` - Entry name
|
|
263
219
|
- `comment?: string` - Entry comment
|
|
@@ -270,11 +226,13 @@ Get entry info. Resolves once all data has been written to the ZIP stream.
|
|
|
270
226
|
- `compressedSize: bigint | number` - Compressed size in bytes
|
|
271
227
|
- `zip64: boolean` - Whether this entry uses ZIP64 format
|
|
272
228
|
|
|
273
|
-
|
|
274
|
-
const entryWriter = zipWriter.createEntryStream({ name: "test.txt" });
|
|
275
|
-
await someStream.pipeTo(entryWriter.writable);
|
|
229
|
+
**Example:**
|
|
276
230
|
|
|
277
|
-
|
|
231
|
+
```ts
|
|
232
|
+
const info = await zipWriter.addEntry({
|
|
233
|
+
readable: dataStream,
|
|
234
|
+
name: "test.txt",
|
|
235
|
+
});
|
|
278
236
|
console.log(
|
|
279
237
|
`Wrote ${info.name}: ${info.uncompressedSize} bytes (compressed to ${info.compressedSize})`,
|
|
280
238
|
);
|
|
@@ -294,24 +252,41 @@ async function createZip() {
|
|
|
294
252
|
const fileStream = Writable.toWeb(createWriteStream("output.zip"));
|
|
295
253
|
zipWriter.readable.pipeTo(fileStream);
|
|
296
254
|
|
|
297
|
-
// Add a text file
|
|
255
|
+
// Add a text file
|
|
298
256
|
const data1 = new TextEncoder().encode("This is a readme");
|
|
299
|
-
await zipWriter.
|
|
300
|
-
|
|
301
|
-
|
|
257
|
+
await zipWriter.addEntry({
|
|
258
|
+
readable: new ReadableStream({
|
|
259
|
+
start(controller) {
|
|
260
|
+
controller.enqueue(data1);
|
|
261
|
+
controller.close();
|
|
262
|
+
},
|
|
263
|
+
}),
|
|
264
|
+
name: "readme.txt",
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Add files from URLs
|
|
302
268
|
const imageResponse = await fetch("https://example.com/image.png");
|
|
303
|
-
await
|
|
304
|
-
|
|
305
|
-
|
|
269
|
+
await zipWriter.addEntry({
|
|
270
|
+
readable: imageResponse.body,
|
|
271
|
+
name: "images/photo.png",
|
|
272
|
+
});
|
|
306
273
|
|
|
307
|
-
// Add a JSON file
|
|
274
|
+
// Add a JSON file
|
|
308
275
|
const data = { hello: "world" };
|
|
309
276
|
const jsonData = new TextEncoder().encode(JSON.stringify(data, null, 2));
|
|
310
|
-
await zipWriter.
|
|
277
|
+
await zipWriter.addEntry({
|
|
278
|
+
readable: new ReadableStream({
|
|
279
|
+
start(controller) {
|
|
280
|
+
controller.enqueue(jsonData);
|
|
281
|
+
controller.close();
|
|
282
|
+
},
|
|
283
|
+
}),
|
|
284
|
+
name: "data.json",
|
|
285
|
+
});
|
|
311
286
|
|
|
312
287
|
// Wait for all entries and check results
|
|
313
|
-
await zipWriter.
|
|
314
|
-
console.log(`Added ${
|
|
288
|
+
const entries = await zipWriter.entries();
|
|
289
|
+
console.log(`Added ${entries.length} entries`);
|
|
315
290
|
|
|
316
291
|
// Finalize the archive
|
|
317
292
|
const result = await zipWriter.finalize();
|
|
@@ -329,9 +304,16 @@ const zipWriter = new ZipWriter();
|
|
|
329
304
|
|
|
330
305
|
// Add entries...
|
|
331
306
|
const data = new TextEncoder().encode("Hello");
|
|
332
|
-
zipWriter
|
|
333
|
-
|
|
334
|
-
|
|
307
|
+
await zipWriter.addEntry({
|
|
308
|
+
readable: new ReadableStream({
|
|
309
|
+
start(controller) {
|
|
310
|
+
controller.enqueue(data);
|
|
311
|
+
controller.close();
|
|
312
|
+
},
|
|
313
|
+
}),
|
|
314
|
+
name: "file.txt",
|
|
315
|
+
});
|
|
316
|
+
await zipWriter.finalize();
|
|
335
317
|
|
|
336
318
|
// Create download link
|
|
337
319
|
const blob = await new Response(zipWriter.readable).blob();
|
|
@@ -410,17 +392,15 @@ No special configuration is needed - it's handled automatically.
|
|
|
410
392
|
|
|
411
393
|
```ts
|
|
412
394
|
try {
|
|
413
|
-
|
|
414
|
-
await someStream.pipeTo(entryWriter.writable);
|
|
415
|
-
await entryWriter.getEntryInfo();
|
|
395
|
+
await zipWriter.addEntry({ readable: someStream, name: "test.txt" });
|
|
416
396
|
} catch (error) {
|
|
417
397
|
console.error("Failed to write entry:", error);
|
|
418
398
|
// The ZIP stream is aborted on error - cannot add more entries
|
|
419
399
|
}
|
|
420
400
|
```
|
|
421
401
|
|
|
422
|
-
Once an error occurs during entry writing, the ZIP stream is
|
|
423
|
-
cannot be recovered. You must create a new `ZipWriter` instance.
|
|
402
|
+
Once an error occurs during entry writing, the ZIP stream is in the errored
|
|
403
|
+
state and cannot be recovered. You must create a new `ZipWriter` instance.
|
|
424
404
|
|
|
425
405
|
## License
|
|
426
406
|
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,17 @@ export interface EntryOptions {
|
|
|
10
10
|
/** Compression method to `STORE` (defaults to `DEFLATE`) */
|
|
11
11
|
store?: boolean;
|
|
12
12
|
}
|
|
13
|
-
export interface
|
|
13
|
+
export interface EntryOptionsInternal extends EntryOptions {
|
|
14
|
+
/** Encoded entry name */
|
|
15
|
+
nameBytes: Uint8Array;
|
|
16
|
+
/** Encoded entry comment */
|
|
17
|
+
commentBytes: Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
export interface Entry extends EntryOptions {
|
|
20
|
+
/** Readable stream of entry data */
|
|
21
|
+
readable: ReadableStream<ArrayBufferView<ArrayBufferLike>>;
|
|
22
|
+
}
|
|
23
|
+
export interface EntryInfoZip64 extends EntryOptionsInternal {
|
|
14
24
|
/** Byte offset of the local file header within the ZIP archive */
|
|
15
25
|
startOffset: bigint;
|
|
16
26
|
/** CRC32 checksum of the uncompressed data */
|
|
@@ -22,10 +32,22 @@ export interface EntryInfoZip64 extends EntryOptions {
|
|
|
22
32
|
/** Entry information is in ZIP64 format */
|
|
23
33
|
zip64: true;
|
|
24
34
|
}
|
|
35
|
+
export interface ZipInfo {
|
|
36
|
+
/** Does the archive use ZIP64 format? */
|
|
37
|
+
zip64: boolean;
|
|
38
|
+
/** Total uncompressed size of all entries */
|
|
39
|
+
uncompressedEntriesSize: bigint;
|
|
40
|
+
/** Total compressed size of all entries */
|
|
41
|
+
compressedEntriesSize: bigint;
|
|
42
|
+
/** Total size of the ZIP file */
|
|
43
|
+
fileSize: bigint;
|
|
44
|
+
}
|
|
25
45
|
export type EntryInfoStandard = {
|
|
26
46
|
[K in keyof EntryInfoZip64]: EntryInfoZip64[K] extends bigint ? number : K extends "zip64" ? false : EntryInfoZip64[K];
|
|
27
47
|
};
|
|
28
|
-
export type
|
|
48
|
+
export type EntryInfoInternal = EntryInfoZip64 | EntryInfoStandard;
|
|
49
|
+
type OmitUnion<T, U extends keyof T> = T extends U ? never : Omit<T, U>;
|
|
50
|
+
export type EntryInfo = OmitUnion<EntryInfoInternal, "nameBytes" | "commentBytes">;
|
|
29
51
|
export declare class ZipWriter<TIsZip64 extends boolean = false> {
|
|
30
52
|
#private;
|
|
31
53
|
/**
|
|
@@ -35,29 +57,10 @@ export declare class ZipWriter<TIsZip64 extends boolean = false> {
|
|
|
35
57
|
crc32?: (data: Uint8Array<ArrayBuffer>, value?: number) => number;
|
|
36
58
|
});
|
|
37
59
|
get readable(): ReadableStream<ArrayBufferView<ArrayBufferLike>>;
|
|
38
|
-
get entries(): ReadonlyArray<Readonly<EntryInfo>>;
|
|
39
60
|
/**
|
|
40
|
-
*
|
|
61
|
+
* Get an array of entry information for all entries added so far to the ZIP archive.
|
|
41
62
|
*/
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Convenience wrapper around `createEntryStream` to write all data at once.
|
|
45
|
-
* Use `createEntryStream` for more efficient streaming writes. Calls to
|
|
46
|
-
* createEntry() will be queued internally and each will resolve once it's
|
|
47
|
-
* written to the archive.
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```ts
|
|
51
|
-
* const data = new TextEncoder().encode("Hello, World!");
|
|
52
|
-
* const entryInfo = await zipWriter.createEntry(data, { name: "hello.txt" });
|
|
53
|
-
* console.log(entryInfo);
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* @param data Entry data
|
|
57
|
-
* @param options Entry filename, comment, compression method, etc.
|
|
58
|
-
* @returns Entry information once the entry has been written.
|
|
59
|
-
*/
|
|
60
|
-
createEntry(data: Uint8Array<ArrayBuffer>, options: EntryOptions): Promise<EntryInfo>;
|
|
63
|
+
entries(): Promise<EntryInfo[]>;
|
|
61
64
|
/**
|
|
62
65
|
* Create a new entry in the Zip archive. Use the returned
|
|
63
66
|
* entryWriter.writable to write data to the entry. You can await
|
|
@@ -84,7 +87,7 @@ export declare class ZipWriter<TIsZip64 extends boolean = false> {
|
|
|
84
87
|
*
|
|
85
88
|
* @param options Entry options
|
|
86
89
|
*/
|
|
87
|
-
|
|
90
|
+
addEntry({ readable, ...entryOptions }: Entry): Promise<EntryInfo>;
|
|
88
91
|
/**
|
|
89
92
|
* Finalize the ZIP archive by writing the central directory and end of
|
|
90
93
|
* central directory records. You may not add any more entries after calling
|
|
@@ -100,39 +103,9 @@ export declare class ZipWriter<TIsZip64 extends boolean = false> {
|
|
|
100
103
|
*
|
|
101
104
|
* @returns Information about the finalized archive.
|
|
102
105
|
*/
|
|
103
|
-
finalize({ entries
|
|
104
|
-
entries?:
|
|
105
|
-
}): Promise<
|
|
106
|
-
/** Does the archive use ZIP64 format? */
|
|
107
|
-
zip64: boolean;
|
|
108
|
-
/** Total uncompressed size of all entries */
|
|
109
|
-
uncompressedEntriesSize: bigint;
|
|
110
|
-
/** Total compressed size of all entries */
|
|
111
|
-
compressedEntriesSize: bigint;
|
|
112
|
-
/** Total size of the ZIP file */
|
|
113
|
-
fileSize: bigint;
|
|
114
|
-
}>;
|
|
115
|
-
}
|
|
116
|
-
declare class EntryWriter {
|
|
117
|
-
#private;
|
|
118
|
-
/**
|
|
119
|
-
* @param enqueueAndPipe Function that enqueues the entry data readable, pipes it to the Zip stream, and returns a promise that resolves to the entry info once done.
|
|
120
|
-
*/
|
|
121
|
-
constructor(enqueueAndPipe: (readable: ReadableStream<Uint8Array<ArrayBuffer>>) => Promise<EntryInfo>);
|
|
122
|
-
/**
|
|
123
|
-
* Writable stream to write entry data to.
|
|
124
|
-
*
|
|
125
|
-
* @example
|
|
126
|
-
* ```ts
|
|
127
|
-
* ReadableStream.from([new TextEncoder().encode("Hello, World!")])
|
|
128
|
-
* .pipeTo(entryWriter.writable);
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
get writable(): WritableStream<Uint8Array<ArrayBuffer>>;
|
|
132
|
-
/**
|
|
133
|
-
* Get entry info. Resolves once all data has been written to the Zip stream.
|
|
134
|
-
*/
|
|
135
|
-
getEntryInfo(): Promise<EntryInfo>;
|
|
106
|
+
finalize({ entries }?: {
|
|
107
|
+
entries?: EntryInfo[];
|
|
108
|
+
}): Promise<ZipInfo>;
|
|
136
109
|
}
|
|
137
110
|
export {};
|
|
138
111
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB;IACjB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,KAAK,CAAC,EAAE,OAAO,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