Skip to content

Commit 8b0bd23

Browse files
Nargonathctalkington
authored andcommitted
Issue #269: Add 'end' event documentation (#284)
1 parent 3009425 commit 8b0bd23

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,19 @@ var archive = archiver('zip', {
2626
});
2727

2828
// listen for all archive data to be written
29+
// 'close' event is fired only when a file descriptor is involved
2930
output.on('close', function() {
3031
console.log(archive.pointer() + ' total bytes');
3132
console.log('archiver has been finalized and the output file descriptor has closed.');
3233
});
3334

35+
// This event is fired when the data source is drained no matter what was the data source.
36+
// It is not part of this library but rather from the NodeJS Stream API.
37+
// @see: https://nodejs.org/api/stream.html#stream_event_end
38+
output.on('end', function() {
39+
console.log('Data has been drained');
40+
});
41+
3442
// good practice to catch warnings (ie stat failures and other non-blocking errors)
3543
archive.on('warning', function(err) {
3644
if (err.code === 'ENOENT') {
@@ -73,6 +81,7 @@ archive.directory('subdir/', false);
7381
archive.glob('subdir/*.txt');
7482

7583
// finalize the archive (ie we are done appending files but streams have to finish yet)
84+
// 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand
7685
archive.finalize();
7786
```
7887

@@ -82,4 +91,4 @@ Archiver ships with out of the box support for TAR and ZIP archives.
8291

8392
You can register additional formats with `registerFormat`.
8493

85-
_Formats will be changing in the next few releases to implement a middleware approach._
94+
_Formats will be changing in the next few releases to implement a middleware approach._

0 commit comments

Comments
 (0)