Created
October 13, 2024 14:41
-
-
Save SerJaimeLannister/da6e55f3cdbb033469055b9f2f44d43e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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