From 5f04eb68a24a489c7b791e39cd511cad2a051441 Mon Sep 17 00:00:00 2001 From: spacemeowx2 Date: Mon, 22 Jan 2024 15:13:05 +0800 Subject: [PATCH] fix: readline throws EOF (fixes #91) --- src/utils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 0bd356a..ae79893 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -12,12 +12,16 @@ const stdinLines = io.readLines(Deno.stdin); export async function readline( { skipEmpty = true }: { skipEmpty?: boolean } = {}, ) { - for await (const line of stdinLines) { + while (true) { + const result = await stdinLines.next(); + if (result.done) { + throw new Error("EOF"); + } + const line = result.value; if (!skipEmpty || line !== "") { return line; } } - throw new Error("EOF"); } export function urlBase64Encode(data: ArrayBuffer) {