v1.0.2
A simple additional function to write to the stdout of the current process with console.write() for Deno.
Repository
Current version released
3 years ago
console.write()
This adds an additional function for the global console object. With console.write() you can write directly to the stdout process of Deno. As I mentioned this function is written for Deno and will only work with the Deno runtime environment! If you use console.write() remember that it is an async function. So you have to await it if needed.
How to use
import
import 'console.ts';syntax
console.write(data : Uint8Array);example
await console.write(new TextEncoder().encode('Hello World!'));output
Hello World!Why not simply use console.log()?
In console.log(), a \n always gets appended to the end as a newline character. With console.write() you can write directly to the stdout and have much more control over it.
As a comparison
using console.log()
console.log('Hello World 1!');
console.log('Hello World 2!');results in:
Hello World 1! <--- Linebreak (\n)
Hello World 2! <--- Linebreak (\n)
<--- New empty lineusing console.write()
await console.write(new TextEncoder().encode('Hello World 1!'));
await console.write(new TextEncoder().encode('Hello World 2!'));results in:
Hello World 1!Hello World 2! <--- No LinebreakFinal words
I hope this little function will help you with your projects. 😜❤