Get stdin as a string or buffer
JavaScript
Clone or download
Latest commit 83c5c9f Mar 2, 2018
Permalink
Failed to load latest commit information.
.editorconfig Fix XO lint issues May 16, 2017
.gitattributes [breaking] ES2015ify and require Node.js 4 Dec 2, 2016
.gitignore Meta tweaks Feb 22, 2018
.npmrc Meta tweaks Feb 22, 2018
.travis.yml Meta tweaks Feb 22, 2018
index.js Avoid using deprecated Buffer constructor (#24) Feb 22, 2018
license Meta tweaks Feb 22, 2018
package.json 6.0.0 Mar 2, 2018
readme.md Meta tweaks Feb 22, 2018
test-buffer.js Meta tweaks Feb 22, 2018
test-real.js Meta tweaks Feb 22, 2018
test.js Meta tweaks Feb 22, 2018

readme.md

get-stdin Build Status

Get stdin as a string or buffer

Install

$ npm install get-stdin

Usage

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

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

API

Both methods 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()

Get stdin as a string.

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

getStdin.buffer()

Get stdin as a Buffer.

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

Related

License

MIT © Sindre Sorhus