91-9990449935 0120-4256464 |
Node.js TTYThe Node.js TTY module contains tty.ReadStream and tty.WriteStream classes. In most cases, there is no need to use this module directly. You have to use require ('tty') to access this module. Syntax: When Node.js discovers that it is being run inside a TTY context, then:
To check that if Node.js is running in a TTY context, use the following command: Class: ReadStreamIt contains a net.Socket subclass that represents the readable portion of a tty. In normal circumstances,the tty.ReadStream has the only instance named process.stdin in any Node.js program (only when isatty(0) is true). rs.isRaw: It is a Boolean that is initialized to false. It specifies the current "raw" state of the tty.ReadStream instance. rs.setRawMode(mode): It should be true or false. It is used to set the properties of the tty.ReadStream to act either as a raw device or default. isRaw will be set to the resulting mode. Class: WriteStreamIt contains a net.Socket subclass that represents the writable portion of a tty. In normal circumstances, the tty.WriteStream has the only instance named process.stdout in any Node.js program (only when isatty(1) is true). Resize event: This event is used when either of the columns or rows properties has changed. Syntax: ws.columns: It is used to give the number of columns the TTY currently has. This property gets updated on 'resize' events. ws.rows: It is used to give the number of rows the TTY currently has. This property gets updated on 'resize' events. Node.js TTY ExampleFile: tty.js Output:
Next TopicNode.js Web Modules
|