fix: readline throws EOF (fixes #91)

splashcat-exporter-v2
spacemeowx2 2024-01-22 15:13:05 +08:00
parent 2c72bb7eaf
commit 5f04eb68a2
1 changed files with 6 additions and 2 deletions

View File

@ -12,12 +12,16 @@ const stdinLines = io.readLines(Deno.stdin);
export async function readline( export async function readline(
{ skipEmpty = true }: { skipEmpty?: boolean } = {}, { 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 !== "") { if (!skipEmpty || line !== "") {
return line; return line;
} }
} }
throw new Error("EOF");
} }
export function urlBase64Encode(data: ArrayBuffer) { export function urlBase64Encode(data: ArrayBuffer) {