{"source":"doc/api/tty.md","modules":[{"textRaw":"TTY","name":"tty","stability": 2,"stabilityText":"Stable","desc":"<p>The <code>tty</code> module provides the <code>tty.ReadStream</code> and <code>tty.WriteStream</code> classes.\nIn most cases, it will not be necessary or possible to use this module directly.\nHowever, it can be accessed using:</p>\n<pre><code class=\"lang-js\">const tty = require(&#39;tty&#39;);\n</code></pre>\n<p>When Node.js detects that it is being run inside a text terminal (&quot;TTY&quot;)\ncontext, the <code>process.stdin</code> will, by default, be initialized as an instance of\n<code>tty.ReadStream</code> and both <code>process.stdout</code> and <code>process.stderr</code> will, by\ndefault be instances of <code>tty.WriteStream</code>. The preferred method of determining\nwhether Node.js is being run within a TTY context is to check that the value of\nthe <code>process.stdout.isTTY</code> property is <code>true</code>:</p>\n<pre><code class=\"lang-sh\">$ node -p -e &quot;Boolean(process.stdout.isTTY)&quot;\ntrue\n$ node -p -e &quot;Boolean(process.stdout.isTTY)&quot; | cat\nfalse\n</code></pre>\n<p>In most cases, there should be little to no reason for an application to\ncreate instances of the <code>tty.ReadStream</code> and <code>tty.WriteStream</code> classes.</p>\n","classes":[{"textRaw":"Class: tty.ReadStream","type":"class","name":"tty.ReadStream","meta":{"added":["v0.5.8"]},"desc":"<p>The <code>tty.ReadStream</code> class is a subclass of <code>net.Socket</code> that represents the\nreadable side of a TTY. In normal circumstances <code>process.stdin</code> will be the\nonly <code>tty.ReadStream</code> instance in a Node.js process and there should be no\nreason to create additional instances.</p>\n","properties":[{"textRaw":"readStream.isRaw","name":"isRaw","meta":{"added":["v0.7.7"]},"desc":"<p>A <code>boolean</code> that is <code>true</code> if the TTY is currently configured to operate as a\nraw device. Defaults to <code>false</code>.</p>\n"}],"methods":[{"textRaw":"readStream.setRawMode(mode)","type":"method","name":"setRawMode","meta":{"added":["v0.7.7"]},"signatures":[{"params":[{"textRaw":"`mode`{boolean}If `true`, configures the `tty.ReadStream` to operate as a raw device. If `false`, configures the `tty.ReadStream` to operate in its default mode. The `readStream.isRaw` property will be set to the resulting mode. ","name":"mode","type":"boolean","desc":"If `true`, configures the `tty.ReadStream` to operate as a raw device. If `false`, configures the `tty.ReadStream` to operate in its default mode. The `readStream.isRaw` property will be set to the resulting mode."}]},{"params":[{"name":"mode"}]}]}]},{"textRaw":"Class: tty.WriteStream","type":"class","name":"tty.WriteStream","meta":{"added":["v0.5.8"]},"desc":"<p>The <code>tty.WriteStream</code> class is a subclass of <code>net.Socket</code> that represents the\nwritable side of a TTY. In normal circumstances, <code>process.stdout</code> and\n<code>process.stderr</code> will be the only <code>tty.WriteStream</code> instances created for a\nNode.js process and there should be no reason to create additional instances.</p>\n","events":[{"textRaw":"Event: 'resize'","type":"event","name":"resize","meta":{"added":["v0.7.7"]},"desc":"<p>The <code>&#39;resize&#39;</code> event is emitted whenever either of the <code>writeStream.columns</code>\nor <code>writeStream.rows</code> properties have changed. No arguments are passed to the\nlistener callback when called.</p>\n<pre><code class=\"lang-js\">process.stdout.on(&#39;resize&#39;, () =&gt;{\n  console.log(&#39;screen size has changed!&#39;);\n  console.log(`${process.stdout.columns}x${process.stdout.rows}`);\n});\n</code></pre>\n","params":[]}],"properties":[{"textRaw":"writeStream.columns","name":"columns","meta":{"added":["v0.7.7"]},"desc":"<p>A <code>number</code> specifying the number of columns the TTY currently has. This property\nis updated whenever the <code>&#39;resize&#39;</code> event is emitted.</p>\n"},{"textRaw":"writeStream.rows","name":"rows","meta":{"added":["v0.7.7"]},"desc":"<p>A <code>number</code> specifying the number of rows the TTY currently has. This property\nis updated whenever the <code>&#39;resize&#39;</code> event is emitted.</p>\n"}]}],"methods":[{"textRaw":"tty.isatty(fd)","type":"method","name":"isatty","meta":{"added":["v0.5.8"]},"signatures":[{"params":[{"textRaw":"`fd`{number}A numeric file descriptor ","name":"fd","type":"number","desc":"A numeric file descriptor"}]},{"params":[{"name":"fd"}]}],"desc":"<p>The <code>tty.isatty()</code> method returns <code>true</code> if the given <code>fd</code> is associated with\na TTY and <code>false</code> if is not.</p>\n"}],"type":"module","displayName":"TTY"}]}