process.stdin


process.stdin 属性返回连接到 stdin (文件描述符 0) 的流。 它是 net.Socket(也就是 Duplex 流),除非文件描述符 0 指向文件,在这种情况下它是 Readable 流。

有关如何从 stdin 读取的详细信息,请参阅 readable.read()

作为 Duplex 流,process.stdin 还可以在为 Node.js v0.10 之前编写的脚本兼容的“旧”模式下使用。 有关更多信息,请参阅流的兼容

在“旧”流模式下,stdin 流默认是暂停的,所以必须调用 process.stdin.resume() 来读取它。 另请注意,调用 process.stdin.resume() 本身会将流切换到“旧”模式。

The process.stdin property returns a stream connected to stdin (fd 0). It is a net.Socket (which is a Duplex stream) unless fd 0 refers to a file, in which case it is a Readable stream.

For details of how to read from stdin see readable.read().

As a Duplex stream, process.stdin can also be used in "old" mode that is compatible with scripts written for Node.js prior to v0.10. For more information see Stream compatibility.

In "old" streams mode the stdin stream is paused by default, so one must call process.stdin.resume() to read from it. Note also that calling process.stdin.resume() itself would switch stream to "old" mode.