You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Sindre Sorhus 63d4a48d11 ES2015ify the tests 9 years ago
.editorconfig ES2015ify the tests 9 years ago
.gitattributes init 11 years ago
.gitignore init 11 years ago
.travis.yml ES2015ify the tests 9 years ago
index.js convert to Promise API 9 years ago
license various tweaks 10 years ago
package.json ES2015ify the tests 9 years ago
readme.md Close #8 PR: Clarify details of now `stdin` is implemented. 9 years ago
test-real.js ES2015ify the tests 9 years ago
test.js ES2015ify the tests 9 years ago

readme.md

get-stdin Build Status

Get stdin as a string or buffer

Install

$ npm install --save get-stdin

Usage

// example.js
const stdin = require('get-stdin');

stdin().then(x => {
	console.log(x);
	//=> 'unicorns'
});
$ echo unicorns | node example.js
unicorns

API

stdin()

Get stdin as a string.

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.

In a TTY context, a promise that resolves to an empty string is returned.

stdin.buffer()

Get stdin as a buffer.

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.

In a TTY context, a promise that resolves to an empty buffer is returned.

License

MIT © Sindre Sorhus