I'm doing some drawings in the terminal and want to hide the return value.
Example:
> process.stdout.write("Hello world");
Hello worldtrue
Thanks!
I'm doing some drawings in the terminal and want to hide the return value.
Example:
> process.stdout.write("Hello world");
Hello worldtrue
Thanks!
I have 2 tricks in my bag that allow you to do this, based on the documentation: Customizing REPL Output
Trick 1
Create a repl.js
file with the following code:
require('repl').start({ prompt: '> ', writer: function myWriter() { return ''} });
Start your REPL with node repl.js
The above code uses the writer
function to customize the output, as mentioned in the docs. You could assign the prompt
blank as well, to further reduce the output.
Trick 2
Type this in your REPL
require('util').inspect = function () { return '' };
The docs hint that the inspect
function is used to format the output, so we are replacing it with a function returning blank to silence the output.