Skip to content
Get stdin as a string or buffer
JavaScript
Find file
Latest commit e89bea4 Jan 7, 2016 1 @sindresorhus fix tests
Failed to load latest commit information.
.editorconfig ES2015ify the tests Oct 14, 2015
.gitattributes init Feb 13, 2014
.gitignore init Feb 13, 2014
.travis.yml Travis CI: Test on Node.js v4.x.x and v5.x.x Dec 30, 2015
index.js convert to Promise API Aug 31, 2015
license various tweaks Aug 4, 2014
package.json fix tests Jan 7, 2016
readme.md readme tweaks Oct 15, 2015
test-buffer.js fix tests Jan 7, 2016
test-real.js
test.js fix tests Jan 7, 2016

readme.md

get-stdin Build Status

Get stdin as a string or buffer

Install

$ npm install --save 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

Something went wrong with that request. Please try again.