stdin2
Get stdin as a string or buffer, using promise. Supports timeout & tty.
Install
$ npm install --save stdin2
Usage
// example.jsconst getStdin =
$ echo unicorns | node example.js
unicorns
Using ES7 await
{ try console catch e console }
API
Function returns a promise that is resolved when the end
event fires on the stdin
stream, indicating that there is no more data to be read.
getStdin([options])
Get stdin
as a string.
Options
- buffer (false) - returns buffer instead of a string
- timeout (Infinity) - rejects after miliseconds, if no data is read
- rejectTTY (false) - rejects if program is run in TTY
License
MIT