Skip to content

Commit

Permalink
Always done on end
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Oct 2, 2023
1 parent 1d948a8 commit 4187ca9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/archive/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const yauzlEntryReadSymlink = async (
entry: yauzl.Entry
) => {
const stream = await yauzlEntryRead(zipfile, entry);
return stream ? streamToBuffer(stream, 'end') : Buffer.alloc(0);
return stream ? streamToBuffer(stream) : Buffer.alloc(0);
};

export interface IZipEntryExtraField {
Expand Down
8 changes: 2 additions & 6 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,9 @@ export function zipPathIsMacResource(path: string) {
* This is however useful for some small streams.
*
* @param stream Readable stream.
* @param doneEvent The stream done event.
* @returns Full buffer.
*/
export async function streamToBuffer(
stream: Readable,
doneEvent: string = 'end'
) {
export async function streamToBuffer(stream: Readable) {
const buffer = await new Promise<Buffer>((resolve, reject) => {
const datas: Buffer[] = [];
let once = false;
Expand All @@ -203,7 +199,7 @@ export async function streamToBuffer(
stream.on('error', err => {
done(err);
});
stream.on(doneEvent, () => {
stream.on('end', () => {
done();
});
});
Expand Down

0 comments on commit 4187ca9

Please sign in to comment.