zip-lib 1.2.3 → 1.3.1

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  # zip-lib
2
- zip and unzip library for node.
2
+ A zip and unzip library for Node.js with promise-based APIs, support for compressing to `Buffer` or extracting from `Buffer`, and advanced features like entry filtering, cancellation, and symlink-aware handling.
3
3
 
4
4
  [![npm Package](https://img.shields.io/npm/v/zip-lib.svg)](https://www.npmjs.org/package/zip-lib)
5
5
  [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/fpsqdb/zip-lib/blob/master/LICENSE)
@@ -34,76 +34,121 @@ npm install zip-lib
34
34
  - Class: [Unzip](#class-unzip)
35
35
  - Options: [IZipOptions](#izipoptions)
36
36
  - Options: [IExtractOptions](#iextractoptions)
37
+ - Event: [IEntryEvent](#event-ientryevent)
37
38
 
38
39
  ## Zip
39
40
  You can use **zip-lib** to compress files or folders.
40
41
 
41
42
  ### Zip single file
42
43
 
43
- ```js
44
- const zl = require("zip-lib");
45
-
46
- zl.archiveFile("path/to/file.txt", "path/to/target.zip").then(function () {
47
- console.log("done");
48
- }, function (err) {
49
- console.log(err);
50
- });
44
+ ```ts
45
+ import * as zl from "zip-lib";
46
+
47
+ async function zipToFile() {
48
+ try {
49
+ await zl.archiveFile("path/to/file.txt", "path/to/target.zip");
50
+ console.log("done");
51
+ } catch (error) {
52
+ console.error(error);
53
+ }
54
+ }
55
+
56
+ async function zipToBuffer() {
57
+ try {
58
+ const buffer = await zl.archiveFile("path/to/file.txt");
59
+ console.log("done", buffer.byteLength);
60
+ } catch (error) {
61
+ console.error(error);
62
+ }
63
+ }
51
64
  ```
52
65
 
53
66
  ### Zip single folder
54
67
 
55
- ```js
56
- const zl = require("zip-lib");
57
-
58
- zl.archiveFolder("path/to/folder", "path/to/target.zip").then(function () {
59
- console.log("done");
60
- }, function (err) {
61
- console.log(err);
62
- });
68
+ ```ts
69
+ import * as zl from "zip-lib";
70
+
71
+ async function zipToFile() {
72
+ try {
73
+ await zl.archiveFolder("path/to/folder", "path/to/target.zip");
74
+ console.log("done");
75
+ } catch (error) {
76
+ console.error(error);
77
+ }
78
+ }
79
+
80
+ async function zipToBuffer() {
81
+ try {
82
+ const buffer = await zl.archiveFolder("path/to/folder");
83
+ console.log("done", buffer.byteLength);
84
+ } catch (error) {
85
+ console.error(error);
86
+ }
87
+ }
63
88
  ```
64
89
 
65
90
  ## Unzip
66
91
 
67
- ```js
68
- const zl = require("zip-lib");
69
-
70
- zl.extract("path/to/target.zip", "path/to/target").then(function () {
71
- console.log("done");
72
- }, function (err) {
73
- console.log(err);
74
- });
92
+ ```ts
93
+ import * as zl from "zip-lib";
94
+
95
+ async function unzipFromFile() {
96
+ try {
97
+ await zl.extract("path/to/target.zip", "path/to/target");
98
+ console.log("done");
99
+ } catch (error) {
100
+ console.error(error);
101
+ }
102
+ }
103
+
104
+ async function unzipFromBuffer(zipBuffer: Buffer) {
105
+ try {
106
+ await zl.extract(zipBuffer, "path/to/target");
107
+ console.log("done");
108
+ } catch (error) {
109
+ console.error(error);
110
+ }
111
+ }
75
112
  ```
76
113
 
77
114
  ## Advanced usage
78
115
 
79
- ### Sets the compression level
80
-
81
- ```js
82
- const zl = require("zip-lib");
83
-
84
- zl.archiveFolder("path/to/folder", "path/to/target.zip", { compressionLevel: 9 }).then(function () {
85
- console.log("done");
86
- }, function (err) {
87
- console.log(err);
88
- });
116
+ ### Set the compression level
117
+
118
+ ```ts
119
+ import * as zl from "zip-lib";
120
+
121
+ async function zipToFile() {
122
+ try {
123
+ await zl.archiveFolder("path/to/folder", "path/to/target.zip", {
124
+ compressionLevel: 9,
125
+ });
126
+ console.log("done");
127
+ } catch (error) {
128
+ console.error(error);
129
+ }
130
+ }
89
131
  ```
90
132
 
91
133
  ### Zip multiple files and folders
92
134
 
93
- ```js
94
- const zl = require("zip-lib");
95
-
96
- const zip = new zl.Zip();
97
- // Adds a file from the file system
98
- zip.addFile("path/to/file.txt");
99
- // Adds a folder from the file system, putting its contents at the root of archive
100
- zip.addFolder("path/to/folder");
101
- // Generate zip file.
102
- zip.archive("path/to/target.zip").then(function () {
103
- console.log("done");
104
- }, function (err) {
105
- console.log(err);
106
- });
135
+ ```ts
136
+ import * as zl from "zip-lib";
137
+
138
+ async function zipToFile() {
139
+ try {
140
+ const zip = new zl.Zip();
141
+ // Adds a file from the file system
142
+ zip.addFile("path/to/file.txt");
143
+ // Adds a folder from the file system, putting its contents at the root of the archive
144
+ zip.addFolder("path/to/folder");
145
+ // Generate the zip file.
146
+ await zip.archive("path/to/target.zip");
147
+ console.log("done");
148
+ } catch (error) {
149
+ console.error(error);
150
+ }
151
+ }
107
152
  ```
108
153
 
109
154
  The `path/to/folder` directory is as follows:
@@ -117,7 +162,7 @@ path/to/folder
117
162
  └── file_in_root.ext
118
163
  ```
119
164
 
120
- And the generated `path/to/target.zip` archive file directory will be as follows:
165
+ And the contents of the generated `path/to/target.zip` archive will be as follows:
121
166
 
122
167
  ```
123
168
  path/to/target.zip
@@ -131,21 +176,24 @@ path/to/target.zip
131
176
 
132
177
  ### Zip with metadata
133
178
 
134
- ```js
135
- const zl = require("zip-lib");
136
-
137
- const zip = new zl.Zip();
138
- // Adds a file from the file system
139
- zip.addFile("path/to/file.txt", "renamedFile.txt");
140
- zip.addFile("path/to/file2.txt", "folder/file.txt");
141
- // Adds a folder from the file system, and naming it `new folder` within the archive
142
- zip.addFolder("path/to/folder", "new folder");
143
- // Generate zip file.
144
- zip.archive("path/to/target.zip").then(function () {
145
- console.log("done");
146
- }, function (err) {
147
- console.log(err);
148
- });
179
+ ```ts
180
+ import * as zl from "zip-lib";
181
+
182
+ async function zipToFile() {
183
+ try {
184
+ const zip = new zl.Zip();
185
+ // Adds a file from the file system
186
+ zip.addFile("path/to/file.txt", "renamedFile.txt");
187
+ zip.addFile("path/to/file2.txt", "folder/file.txt");
188
+ // Adds a folder from the file system and names it `new folder` within the archive
189
+ zip.addFolder("path/to/folder", "new folder");
190
+ // Generate the zip file.
191
+ zip.archive("path/to/target.zip");
192
+ console.log("done");
193
+ } catch (error) {
194
+ console.error(error);
195
+ }
196
+ }
149
197
  ```
150
198
 
151
199
  The `path/to/folder` directory is as follows:
@@ -159,7 +207,7 @@ path/to/folder
159
207
  └── file_in_root.ext
160
208
  ```
161
209
 
162
- And the generated `path/to/target.zip` archive file directory will be as follows:
210
+ And the contents of the generated `path/to/target.zip` archive will be as follows:
163
211
 
164
212
  ```
165
213
  path/to/target.zip
@@ -167,7 +215,7 @@ path/to/target.zip
167
215
  ├── renamedFile.txt
168
216
  ├── folder
169
217
  │ ├── file.txt
170
- │── new folder
218
+ ├── new folder
171
219
  ├── dir1
172
220
  │ ├── file.ext
173
221
  ├── dir2
@@ -175,208 +223,251 @@ path/to/target.zip
175
223
  ```
176
224
 
177
225
  ### Unzip with entry callback
178
- Using `onEntry` callback we can know the current progress of extracting and control the extraction operation. See [IExtractOptions](#iextractoptions).
179
-
180
- ```js
181
- const zl = require("zip-lib");
182
-
183
- const unzip = new zl.Unzip({
184
- // Called before an item is extracted.
185
- onEntry: function (event) {
186
- console.log(event.entryCount, event.entryName);
187
- }
188
- })
189
- unzip.extract("path/to/target.zip", "path/to/target").then(function () {
190
- console.log("done");
191
- }, function (err) {
192
- console.log(err);
193
- });
226
+ Using the `onEntry` callback, we can track extraction progress and control the extraction process. See [IExtractOptions](#iextractoptions).
227
+
228
+ ```ts
229
+ import * as zl from "zip-lib";
230
+
231
+ async function unzipFromFile() {
232
+ try {
233
+ const unzip = new zl.Unzip({
234
+ // Called before an item is extracted.
235
+ onEntry: (event) => {
236
+ console.log(event.entryCount, event.entryName);
237
+ },
238
+ });
239
+ await unzip.extract("path/to/target.zip", "path/to/target");
240
+ console.log("done");
241
+ } catch (error) {
242
+ console.error(error);
243
+ }
244
+ }
194
245
  ```
195
246
 
196
247
  ### Unzip and exclude specified entries
197
248
  The following code shows how to exclude the `__MACOSX` folder in the zip file when extracting. See [IExtractOptions](#iextractoptions).
198
249
 
199
- ```js
200
- const zl = require("zip-lib");
201
-
202
- const unzip = new zl.Unzip({
203
- // Called before an item is extracted.
204
- onEntry: function (event) {
205
- if (/^__MACOSX\//.test(event.entryName)) {
206
- // entry name starts with __MACOSX/
207
- event.preventDefault();
208
- }
209
- }
210
- })
211
- unzip.extract("path/to/target.zip", "path/to/target").then(function () {
212
- console.log("done");
213
- }, function (err) {
214
- console.log(err);
215
- });
250
+ ```ts
251
+ import * as zl from "zip-lib";
252
+
253
+ async function unzipFromFile() {
254
+ try {
255
+ const unzip = new zl.Unzip({
256
+ // Called before an item is extracted.
257
+ onEntry: (event) => {
258
+ if (/^__MACOSX\//.test(event.entryName)) {
259
+ // entry name starts with __MACOSX/
260
+ event.preventDefault();
261
+ }
262
+ },
263
+ });
264
+ await unzip.extract("path/to/target.zip", "path/to/target");
265
+ console.log("done");
266
+ } catch (error) {
267
+ console.error(error);
268
+ }
269
+ }
216
270
  ```
217
271
 
218
272
  ### Cancel zip
219
273
  If the `cancel` method is called after the archive is complete, nothing will happen.
220
274
 
221
- ```js
222
- const zl = require("zip-lib");
275
+ ```ts
276
+ import * as zl from "zip-lib";
223
277
 
224
278
  const zip = new zl.Zip();
225
- zip.addFile("path/to/file.txt");
226
- zip.archive("path/to/target.zip").then(function () {
227
- console.log("done");
228
- }, function (err) {
229
- if (err.name === "Canceled") {
230
- console.log("cancel");
231
- } else {
232
- console.log(err);
233
- }
234
- });
235
-
236
- // Cancel zip
237
- zip.cancel();
279
+ async function zipToFile() {
280
+ try {
281
+ zip.addFile("path/to/file.txt");
282
+ await zip.archive("path/to/target.zip");
283
+ console.log("done");
284
+ } catch (error) {
285
+ if (error instanceof Error && error.name === "Canceled") {
286
+ console.log("cancel");
287
+ } else {
288
+ console.log(error);
289
+ }
290
+ }
291
+ }
292
+
293
+ function cancel() {
294
+ zip.cancel();
295
+ }
238
296
  ```
239
297
 
240
298
  ### Cancel unzip
241
299
  If the `cancel` method is called after the extract is complete, nothing will happen.
242
300
 
243
- ```js
244
- const zl = require("zip-lib");
301
+ ```ts
302
+ import * as zl from "zip-lib";
245
303
 
246
304
  const unzip = new zl.Unzip();
247
- unzip.extract("path/to/target.zip", "path/to/target").then(function () {
248
- console.log("done");
249
- }, function (err) {
250
- if (err.name === "Canceled") {
251
- console.log("cancel");
252
- } else {
253
- console.log(err);
254
- }
255
- });
256
-
257
- // cancel
258
- unzip.cancel();
305
+ async function unzipFromFile() {
306
+ try {
307
+ await unzip.extract("path/to/target.zip", "path/to/target");
308
+ console.log("done");
309
+ } catch (error) {
310
+ if (error instanceof Error && error.name === "Canceled") {
311
+ console.log("cancel");
312
+ } else {
313
+ console.log(error);
314
+ }
315
+ }
316
+ }
317
+
318
+ function cancel() {
319
+ unzip.cancel();
320
+ }
259
321
  ```
260
322
 
261
323
  ## API
262
324
 
325
+ Choose the API based on how much control you need:
326
+
327
+ - Use [`archiveFile`](#archivefile), [`archiveFolder`](#archivefolder), and [`extract`](#extract) for simple one-shot operations.
328
+ - Use [`Zip`](#class-zip) when you need to add multiple files or folders, rename entries, or cancel compression.
329
+ - Use [`Unzip`](#class-unzip) when you need to filter entries with `onEntry` or cancel extraction.
330
+
263
331
  ### Method: archiveFile <a id="archivefile"></a>
264
332
 
265
- **archiveFile(file, zipFile, [options])**
333
+ Compress a single file.
266
334
 
267
- Compress a single file to zip.
335
+ ```ts
336
+ archiveFile(file: string, options?: IZipOptions): Promise<Buffer>
337
+ archiveFile(file: string, zipFile: string, options?: IZipOptions): Promise<void>
338
+ ```
268
339
 
269
- - `file`: String
270
- - `zipFile`: String
271
- - `options?`: [IZipOptions](#izipoptions) (optional)
340
+ - `file`: Path to the source file.
341
+ - `zipFile`: Optional output zip file path.
342
+ - `options`: Optional [IZipOptions](#izipoptions).
272
343
 
273
- Returns: `Promise<viod>`
344
+ If `zipFile` is provided, the archive is written to disk and the method returns `Promise<void>`. Otherwise it returns the generated zip as a `Buffer`.
274
345
 
275
346
  ### Method: archiveFolder <a id="archivefolder"></a>
276
347
 
277
- **archiveFolder(folder, zipFile, [options])**
348
+ Compress all contents of a folder.
278
349
 
279
- Compress all the contents of the specified folder to zip.
350
+ ```ts
351
+ archiveFolder(folder: string, options?: IZipOptions): Promise<Buffer>
352
+ archiveFolder(folder: string, zipFile: string, options?: IZipOptions): Promise<void>
353
+ ```
280
354
 
281
- - `folder`: String
282
- - `zipFile`: String
283
- - `options?`: [IZipOptions](#izipoptions) (optional)
355
+ - `folder`: Path to the source folder.
356
+ - `zipFile`: Optional output zip file path.
357
+ - `options`: Optional [IZipOptions](#izipoptions).
284
358
 
285
- Returns: `Promise<void>`
359
+ If `zipFile` is provided, the archive is written to disk and the method returns `Promise<void>`. Otherwise it returns the generated zip as a `Buffer`.
286
360
 
287
361
  ### Method: extract <a id="extract"></a>
288
362
 
289
- **extract(zipFile, targetFolder, [options])**
290
-
291
- Extract the zip file to the specified location.
292
-
293
- - `zipFile`: String
294
- - `targetFolder`: String
295
- - `options?`: [IExtractOptions](#iextractoptions) (optional)
296
-
297
- Returns: `Promise<void>`
298
-
299
- ### Class: Zip<a id="class-zip"></a>
300
- Compress files or folders to a zip file.
301
-
302
- **Constructor: new Zip([options])**
363
+ Extract a zip file or zip buffer to a target folder.
303
364
 
304
- - `options?`: [IZipOptions](#izipoptions)
305
-
306
- **Method: addFile(file, [metadataPath])**
307
-
308
- Adds a file from the file system at realPath into the zipfile as metadataPath.
309
-
310
- - `file`: String
311
- - `metadataPath?`: String (optional) - Typically metadataPath would be calculated as path.relative(root, realPath). A valid metadataPath must not start with `/` or `/[A-Za-z]:\//`, and must not contain `..`.
312
-
313
- Returns: `void`
365
+ ```ts
366
+ extract(zipFile: string, targetFolder: string, options?: IExtractOptions): Promise<void>
367
+ extract(zipBuffer: Buffer, targetFolder: string, options?: IExtractOptions): Promise<void>
368
+ ```
314
369
 
315
- **Method: addFolder(folder, [metadataPath])**
370
+ - `zipFile`: Path to a zip file on disk.
371
+ - `zipBuffer`: A zip archive in memory.
372
+ - `targetFolder`: Destination folder.
373
+ - `options`: Optional [IExtractOptions](#iextractoptions).
316
374
 
317
- Adds a folder from the file system at realPath into the zipfile as metadataPath.
375
+ ### Class: Zip <a id="class-zip"></a>
318
376
 
319
- - `folder`: String
320
- - `metadataPath?`: String (optional) - Typically metadataPath would be calculated as path.relative(root, realPath). A valid metadataPath must not start with `/` or `/[A-Za-z]:\//`, and must not contain `..`.
377
+ Build an archive incrementally when the top-level helpers are not enough.
321
378
 
322
- Returns: `void`
379
+ **Constructor**
323
380
 
324
- **Method: archive(zipFile)**
381
+ ```ts
382
+ new Zip(options?: IZipOptions)
383
+ ```
325
384
 
326
- Generate zip file.
385
+ - `options`: Optional [IZipOptions](#izipoptions).
327
386
 
328
- - `zipFile`: String
387
+ **Methods**
329
388
 
330
- Returns: `Promise<viod>`
389
+ ```ts
390
+ addFile(file: string, metadataPath?: string): void
391
+ addFolder(folder: string, metadataPath?: string): void
392
+ archive(): Promise<Buffer>
393
+ archive(zipFile: string): Promise<void>
394
+ cancel(): void
395
+ ```
331
396
 
332
- **Method: cancel()**
397
+ - `addFile`: Adds one file to the archive.
398
+ - `addFolder`: Adds one folder to the archive.
399
+ - `metadataPath`: Optional path stored inside the zip. A valid `metadataPath` must not start with `/` or `/[A-Za-z]:\//`, and must not contain `..`.
400
+ - `archive()`: Returns the zip as a `Buffer`.
401
+ - `archive(zipFile)`: Writes the zip directly to disk.
402
+ - `cancel()`: Cancels compression. Calling it after completion has no effect.
333
403
 
334
- Cancel compression. If the `cancel` method is called after the archive is complete, nothing will happen.
404
+ Use `metadataPath` to rename files or folders inside the archive. It is typically computed with `path.relative(root, realPath)`.
335
405
 
336
- Returns: `void`
406
+ ### Class: Unzip <a id="class-unzip"></a>
337
407
 
338
- ### Class: Unzip<a id="class-unzip"></a>
339
- Extract the zip file.
408
+ Extract with entry filtering and cancellation support.
340
409
 
341
- **Constructor: new Unzip([options])**
410
+ **Constructor**
342
411
 
343
- - `options?`: [IZipOptions](#izipoptions) (optional)
412
+ ```ts
413
+ new Unzip(options?: IExtractOptions)
414
+ ```
344
415
 
345
- **Method: extract(zipFile, targetFolder)**
416
+ - `options`: Optional [IExtractOptions](#iextractoptions).
346
417
 
347
- Extract the zip file to the specified location.
418
+ **Methods**
348
419
 
349
- - `zipFile`: String
350
- - `targetFolder`: String
420
+ ```ts
421
+ extract(zipFile: string, targetFolder: string): Promise<void>
422
+ extract(zipBuffer: Buffer, targetFolder: string): Promise<void>
423
+ cancel(): void
424
+ ```
351
425
 
352
- Returns: `Promise<void>`
426
+ - `extract(...)`: Extracts from a zip file path or a `Buffer`.
427
+ - `cancel()`: Cancels extraction. Calling it after completion has no effect.
353
428
 
354
- **Method: cancel()**
429
+ ### Options: IZipOptions <a id="izipoptions"></a>
355
430
 
356
- If the `cancel` method is called after the extract is complete, nothing will happen.
431
+ ```ts
432
+ interface IZipOptions {
433
+ followSymlinks?: boolean;
434
+ compressionLevel?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
435
+ }
436
+ ```
357
437
 
358
- Returns: `void`
438
+ - `followSymlinks`: Default `false`. If `true`, adds the target of a symbolic link. If `false`, adds the symbolic link itself.
439
+ - `compressionLevel`: Default `6`. Use `0` to store file data without compression, or `1`-`9` to deflate file data.
359
440
 
360
- ### Options: IZipOptions <a id="izipoptions"></a>
441
+ ### Options: IExtractOptions <a id="iextractoptions"></a>
361
442
 
362
- Object
363
- - `followSymlinks?`: Boolean (optional) - Indicates how to handle when the given path is a symbolic link. The default value is `false`.<br>`true`: add the target of the symbolic link to the zip.<br>`false`: add symbolic link itself to the zip.
364
- - `compressionLevel?`: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 - Sets the compression level. The default value is `6`.<br>`0`: the file data will be stored.<br>`1-9`: the file data will be deflated.
443
+ ```ts
444
+ interface IExtractOptions {
445
+ overwrite?: boolean;
446
+ safeSymlinksOnly?: boolean;
447
+ symlinkAsFileOnWindows?: boolean;
448
+ onEntry?: (event: IEntryEvent) => void;
449
+ }
450
+ ```
365
451
 
366
- ### Options: IExtractOptions <a id="iextractoptions"></a>
452
+ - `overwrite`: Default `false`. If `true`, deletes the target directory before extraction.
453
+ - `safeSymlinksOnly`: Default `false`. If `true`, refuses to create symlinks whose targets are outside the extraction root.
454
+ - `symlinkAsFileOnWindows`: Default `true`. On Windows, if `true`, symbolic links are extracted as regular files. If `false`, the library tries to create real symbolic links instead. This may fail with `EPERM` when the current process is not allowed to create symlinks. Keep the default for better compatibility; set this to `false` only if you want to preserve symlinks as symlinks.
455
+ - `onEntry`: Called before an entry is extracted. Use it to inspect or skip entries.
367
456
 
368
- Object
369
- - `overwrite?`: Boolean (optional) - If it is true, the target directory will be deleted before extract. The default value is `false`.
370
- - `safeSymlinksOnly`: Boolean (optional) - Controls the creation phase of symlinks. The default value is `false`.<br>`true`: Refuses to create any symlink whose target is outside the extraction root.<br>`false`: Allows creating external symlinks. **Note:** Subsequent write operations to these links will still be intercepted by the separate AFWRITE security layer.
371
- - `symlinkAsFileOnWindows?`: Boolean (optional) - Extract symbolic links as files on Windows. This value is only available on Windows and ignored on other platforms. The default value is `true`.<br>If `true`, the symlink in the zip will be extracted as a normal file on Windows.<br>If `false`, the symlink in the zip will be extracted as a symlink correctly on Windows, but an `EPERM` error will be thrown under non-administrators.
457
+ > WARNING: On Windows, creating symbolic links may require administrator privileges, depending on system policy. If Windows Developer Mode is enabled, non-administrator processes can usually create symlinks as well. If `symlinkAsFileOnWindows` is `false` and the current process is not allowed to create symlinks, extraction may fail with `EPERM`.
372
458
 
373
- > ⚠**WARNING:** On Windows, the default security policy allows only administrators to create symbolic links. If you set `symlinkAsFileOnWindows` to `false` and the zip contains symlink, be sure to run the code under the administrator, otherwise an `EPERM` error will be thrown.
459
+ ### Event: IEntryEvent
374
460
 
375
- - `onEntry?`: Function (optional) - Called before an item is extracted.<br>Arguments:
376
- - `event`: Object - Represents an event that an entry is about to be extracted.
377
- - `entryName`: String (readonly) - Entry name.
378
- - `entryCount`: Number (readonly) - Total number of entries.
379
- - `preventDefault()`: Function - Prevent extracting current entry. This method can be used to prevent extraction of the current item. By calling this method we can control which items can be extracted.
461
+ ```ts
462
+ interface IEntryEvent {
463
+ readonly entryName: string;
464
+ readonly entryCount: number;
465
+ preventDefault(): void;
466
+ }
467
+ ```
380
468
 
469
+ - `entryName`: The current entry name.
470
+ - `entryCount`: The total number of entries in the archive.
471
+ - `preventDefault()`: Skips the current entry.
381
472
  # License
382
- Licensed under the [MIT](https://github.com/fpsqdb/zip-lib/blob/master/LICENSE) license.
473
+ Licensed under the [MIT](https://github.com/fpsqdb/zip-lib/blob/master/LICENSE) license.
package/lib/fs.d.ts CHANGED
@@ -20,5 +20,6 @@ export declare function readdirp(folder: string): Promise<FileEntry[]>;
20
20
  export declare function getFileEntry(target: string): Promise<FileEntry>;
21
21
  export declare function ensureFolder(folder: string): Promise<FolderStat>;
22
22
  export declare function pathExists(target: string): Promise<boolean>;
23
+ export declare function statFolder(folder: string): Promise<FolderStat | undefined>;
23
24
  export declare function rimraf(target: string): Promise<void>;
24
25
  export declare function isRootPath(target: string): boolean;