Skip to content

Instantly share code, notes, and snippets.

@SerJaimeLannister
Created October 13, 2024 14:41
Show Gist options
  • Select an option

  • Save SerJaimeLannister/da6e55f3cdbb033469055b9f2f44d43e to your computer and use it in GitHub Desktop.

Select an option

Save SerJaimeLannister/da6e55f3cdbb033469055b9f2f44d43e to your computer and use it in GitHub Desktop.
const decoder = new TextDecoder();
export async function* readStdin() {
for await (const chunk of Deno.stdin.readable) {
const text = decoder.decode(chunk, { stream: true });
const lines = text.split("\n");
for (const line of lines) {
if (line) {
yield line; // Yield each non-empty line
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment