get-stdin
Get stdin as a string or buffer
Last updated 6 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm
$ cnpm install get-stdin 
SYNC missed versions from official npm registry.

get-stdin Build Status

Get stdin as a string or buffer

Install

$ npm install get-stdin

Usage

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

(async () => {
	console.log(await getStdin());
	//=> '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

Current Tags

  • 9.0.0                                ...           latest (4 years ago)

7 Versions

  • 9.0.0                                ...           4 years ago
  • 0.1.0                                ...           12 years ago
  • 8.0.0                                ...           5 years ago
  • 5.0.1                                ...           10 years ago
  • 7.0.0                                ...           6 years ago
  • 6.0.0                                ...           7 years ago
  • 4.0.1                                ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (5)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org