From 4187ca92a58b5e42c0ad4a8fc14d00ebecef2bf7 Mon Sep 17 00:00:00 2001 From: JrMasterModelBuilder Date: Mon, 2 Oct 2023 01:08:57 -0400 Subject: [PATCH] Always done on end --- src/archive/zip.ts | 2 +- src/util.ts | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/archive/zip.ts b/src/archive/zip.ts index 17a6eaf..6c6a4ba 100644 --- a/src/archive/zip.ts +++ b/src/archive/zip.ts @@ -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 { diff --git a/src/util.ts b/src/util.ts index 63ea56d..b60b700 100644 --- a/src/util.ts +++ b/src/util.ts @@ -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((resolve, reject) => { const datas: Buffer[] = []; let once = false; @@ -203,7 +199,7 @@ export async function streamToBuffer( stream.on('error', err => { done(err); }); - stream.on(doneEvent, () => { + stream.on('end', () => { done(); }); });