我如何知道Node.js中的process.stdin是否为空?

问题描述

我的应用程序有两个用例:要么用户将在process.stdin中提供内容,例如以下示例:

$ echo "content to parse" | app

或将应用程序指向文件

$ app file-to-parse.txt

Documentation for process.stdinthe list of events in net.socket

我可以监听datareadableend之类的事件,但是如果process.stdin为空,则不会调用任何事件。因此,启动应用程序时如何确定process.stdin是否为空?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)