What does
process.stdout.connect({})
do and how can I use it?
Tryied googleing it but found nothing. Tryied options but get error:
TypeError: self._handle.connect is not a function
CodePudding user response:
As the documentation says, process.stdout
returns a stream connected to stdout and that stream is of type Socket
. Now, if you check the documentation for Socket
and look for the connect
method you'll find that it initiates a connection on a given socket.
In order to use process.stdout
you don't actually need to call connect
, you can just write arbitrary strings to the stream which will get echoed in your stdout, e.g.
process.stdout.write("test"); // will print test to the console
But if logging to the console is your intent, it's probably easier to just use the provided console.log()
which adds a lot of formatting and other stuff (see this for further info).