Object built-in object

objectTTYInputStream

ttyread stream object forttyread, write

There is no way to create this class alone, there are only process.stdininstances

1
process.stdin.read(1)

inheritance relationship

member attribute

isTTY

Boolean, always true

1
readonly Boolean TTYInputStream.isTTY;

isRaw

Boolean, the query is in raw mode, when it is true, it meansttyWhen configured to operate as a raw device

1
readonly Boolean TTYInputStream.isRaw;

fd

Integer, queryStreamThe corresponding file descriptor value, implemented by subclasses

1
readonly Integer TTYInputStream.fd;

member function

setRawMode

set upttyWhether to work in raw mode

1
TTYInputStream TTYInputStream.setRawMode(Boolean isRawMode);

Call parameters:

  • isRawMode: Boolean, if it is true, it means to work in raw mode; otherwise, it will work in default mode. readStream.isRawIt will be set by this method

return result:

  • TTYInputStream, returns itself

read

Read data of the specified size from the stream

1
Buffer TTYInputStream.read(Integer bytes = -1) async;

Call parameters:

  • bytes: Integer, specify the amount of data to read, the default is to read data blocks of random size, the size of the read data depends on the device

return result:

  • Buffer, returns the data read from the stream, or null if there is no data to read or the connection is interrupted

write

writes the given data to the stream

1
TTYInputStream.write(Buffer data) async;

Call parameters:

  • data:Buffer, given the data to be written

flush

Write the contents of the file buffer to the physical device

1
TTYInputStream.flush() async;

close

close the current stream object

1
TTYInputStream.close() async;

copyTo

Copy stream data to target stream

1 2
Long TTYInputStream.copyTo(Stream stm, Long bytes = -1) async;

Call parameters:

  • stm:Stream, the target stream object
  • bytes: Long, the number of bytes copied

return result:

  • Long, returns the number of bytes copied

toString

Return the string representation of the object, generally return "[Native Object]", the object can be reimplemented according to its own characteristics

1
String TTYInputStream.toString();

return result:

  • String, returns a string representation of the object

toJSON

Returns the JSON format representation of the object, generally returns a collection of readable properties defined by the object

1
Value TTYInputStream.toJSON(String key = "");

Call parameters:

  • key: String, not used

return result:

  • Value, which returns a JSON-serializable value