async function main () {
let input: Stdin | FsFile;
let decoder = new TextDecoder();
console.log("Reading from helloworld.txt");
// Try to read a named text file
input = await Deno.open("helloworld.txt");
for await(const chunk of input.readable) {
console.log(decoder.decode(chunk));
}
// Now try to read from standard input
console.log("Type in some text and press Ctrl-C to exit");
input = Deno.stdin;
for await(const chunk of input.readable) {
console.log(decoder.decode(chunk));
}
}
if (import.meta.main) main();
async function main () {
let input: Stdin | FsFile;
let decoder = new TextDecoder();
console.log("Reading from helloworld.txt");
// Try to read a named text file
input = await Deno.open("helloworld.txt");
for await(const chunk of input.readable) {
console.log(decoder.decode(chunk));
}
// Now try to read from standard input
console.log("Type in some text and press Ctrl-C to exit");
input = Deno.stdin;
for await(const chunk of input.readable) {
console.log(decoder.decode(chunk));
}
}
if (import.meta.main) main();