Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

read-cli-input

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-cli-input

Read user input from CLI for specified amount of lines.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

read-cli-input

Read user input from CLI for specified amount of lines.

Install

$ npm install read-cli-input

Usage

var read = require('read-cli-input')

console.log("What are your most favorite 3 food ?");

read(3, function (input) {
  console.log('Answer was: ', input.join(', '));
  // => Answer was Falafel, ramen, babi guling
})

By default, it reads from process.stdin. You can specify custom stdin, and a function to generate a prefix for multi-line inputs.

read({ stdin: process.stdin, lines: 3, prefix: prefix }, console.log);

function prefix (line) {
  process.stdout.write(line + 1 + '.'); // It'll output "1." "2." "3." ...
}

If you'll read just one line from process.stdin, you can just pass a callback:

read(console.log);

Keywords

FAQs

Package last updated on 27 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc