Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including get-stdin with all npm packages installed. Try it out:

var getStdin = require("get-stdin")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

get-stdin v8.0.0

Get stdin as a string or buffer

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


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free