Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#71523 fix(yazl): make zipfile extend event…
Browse files Browse the repository at this point in the history
… emitter by @luxass
  • Loading branch information
luxass authored Feb 4, 2025
1 parent 95b103b commit 137abc9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion types/yazl/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="node" />

import { Buffer } from "buffer";
import { EventEmitter } from "events";

export interface Options {
mtime: Date;
Expand All @@ -27,7 +28,7 @@ export interface DosDateTime {
time: number;
}

export class ZipFile {
export class ZipFile extends EventEmitter {
addFile(realPath: string, metadataPath: string, options?: Partial<Options>): void;
outputStream: NodeJS.ReadableStream;
addReadStream(input: NodeJS.ReadableStream, metadataPath: string, options?: Partial<ReadStreamOptions>): void;
Expand Down
4 changes: 4 additions & 0 deletions types/yazl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
{
"name": "Sean Marvi Oliver Genabe",
"githubUsername": "seangenabe"
},
{
"name": "Lucas Nørgård",
"githubUsername": "luxass"
}
]
}
6 changes: 6 additions & 0 deletions types/yazl/yazl-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ zipfile.addFile("path/to/file.txt", "path/in/zipfile.txt");
// pipe() can be called any time after the constructor
// $ExpectType ReadableStream
zipfile.outputStream;

// $ExpectType ZipFile
zipfile.on("error", (err) => {
console.error("error", err);
});

zipfile.outputStream.pipe(fs.createWriteStream("output.zip")).on("close", () => {
console.log("done");
});
Expand Down

0 comments on commit 137abc9

Please sign in to comment.