Your IP : 216.73.216.213
{
"source": "doc/api/tty.md",
"modules": [
{
"textRaw": "TTY",
"name": "tty",
"introduced_in": "v0.10.0",
"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('tty');\n</code></pre>\n<p>When Node.js detects that it is being run with a text terminal ("TTY")\nattached, <a href=\"process.html#process_process_stdin\"><code>process.stdin</code></a> will, by default, be initialized as an instance of\n<code>tty.ReadStream</code> and both <a href=\"process.html#process_process_stdout\"><code>process.stdout</code></a> and <a href=\"process.html#process_process_stderr\"><code>process.stderr</code></a> 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 "Boolean(process.stdout.isTTY)"\ntrue\n$ node -p -e "Boolean(process.stdout.isTTY)" | cat\nfalse\n</code></pre>\n<p>In most cases, there should be little to no reason for an application to\nmanually create instances of the <code>tty.ReadStream</code> and <code>tty.WriteStream</code>\nclasses.</p>\n",
"classes": [
{
"textRaw": "Class: tty.ReadStream",
"type": "class",
"name": "tty.ReadStream",
"meta": {
"added": [
"v0.5.8"
],
"changes": []
},
"desc": "<p>The <code>tty.ReadStream</code> class is a subclass of <a href=\"net.html#net_class_net_socket\"><code>net.Socket</code></a> that represents the\nreadable side of a TTY. In normal circumstances <a href=\"process.html#process_process_stdin\"><code>process.stdin</code></a> 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"
],
"changes": []
},
"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"
},
{
"textRaw": "readStream.isTTY",
"name": "isTTY",
"meta": {
"added": [
"v0.5.8"
],
"changes": []
},
"desc": "<p>A <code>boolean</code> that is always <code>true</code> for <code>tty.ReadStream</code> instances.</p>\n"
}
],
"methods": [
{
"textRaw": "readStream.setRawMode(mode)",
"type": "method",
"name": "setRawMode",
"meta": {
"added": [
"v0.7.7"
],
"changes": []
},
"desc": "<p>Allows configuration of <code>tty.ReadStream</code> so that it operates as a raw device.</p>\n<p>When in raw mode, input is always available character-by-character, not\nincluding modifiers. Additionally, all special processing of characters by the\nterminal is disabled, including echoing input characters.\nNote that <code>CTRL</code>+<code>C</code> will no longer cause a <code>SIGINT</code> when in this mode.</p>\n<ul>\n<li><code>mode</code> {boolean} If <code>true</code>, configures the <code>tty.ReadStream</code> to operate as a\nraw device. If <code>false</code>, configures the <code>tty.ReadStream</code> to operate in its\ndefault mode. The <code>readStream.isRaw</code> property will be set to the resulting\nmode.</li>\n</ul>\n",
"signatures": [
{
"params": [
{
"name": "mode"
}
]
}
]
}
]
},
{
"textRaw": "Class: tty.WriteStream",
"type": "class",
"name": "tty.WriteStream",
"meta": {
"added": [
"v0.5.8"
],
"changes": []
},
"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, <a href=\"process.html#process_process_stdout\"><code>process.stdout</code></a> and\n<a href=\"process.html#process_process_stderr\"><code>process.stderr</code></a> 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"
],
"changes": []
},
"desc": "<p>The <code>'resize'</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('resize', () => {\n console.log('screen size has changed!');\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"
],
"changes": []
},
"desc": "<p>A <code>number</code> specifying the number of columns the TTY currently has. This property\nis updated whenever the <code>'resize'</code> event is emitted.</p>\n"
},
{
"textRaw": "writeStream.isTTY",
"name": "isTTY",
"meta": {
"added": [
"v0.5.8"
],
"changes": []
},
"desc": "<p>A <code>boolean</code> that is always <code>true</code>.</p>\n"
},
{
"textRaw": "writeStream.rows",
"name": "rows",
"meta": {
"added": [
"v0.7.7"
],
"changes": []
},
"desc": "<p>A <code>number</code> specifying the number of rows the TTY currently has. This property\nis updated whenever the <code>'resize'</code> event is emitted.</p>\n"
}
]
}
],
"methods": [
{
"textRaw": "tty.isatty(fd)",
"type": "method",
"name": "isatty",
"meta": {
"added": [
"v0.5.8"
],
"changes": []
},
"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 it is not, including whenever <code>fd</code> is not a non-negative\ninteger.</p>\n"
}
],
"type": "module",
"displayName": "TTY"
}
]
}