Socket
Socket
Sign inDemoInstall

read

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    read

read(1) for node programs


Version published
Weekly downloads
4.6M
decreased by-3.61%
Maintainers
1
Install size
10.5 kB
Created
Weekly downloads
 

Readme

Source

For reading user input from stdin.

USAGE

var read = require("read")
read(options, callback)

The callback gets called with either the user input, or the default specified, or an error, in the traditional callback(error, result) node style.

OPTIONS

Every option is optional.

  • prompt What to write to stdout before reading input.
  • silent Don't echo the output as the user types it.
  • num Max number of chars to read from terminal.
  • timeout Number of ms to wait for user input before giving up.
  • default The default value if the user enters nothing.
  • stdin Readable stream to get input data from. (default process.stdin)
  • stdout Writeable stream to write prompts to. (default: process.stdout)

If silent is true, or num is set, and the input is a TTY, then read will set raw mode, and read character by character.

At this time, backspace and arrow keys are not supported very well. It's probably not too hard to add support for this, perhaps using node's built-in readline module.

CONTRIBUTING

Patches welcome.

BUGS

In node 0.6.0 through 0.6.5, you must explicitly call process.stdin.destroy() or process.exit() when you know that your program is done reading, or else it will keep the event loop running forever.

See: https://github.com/joyent/node/issues/2257

FAQs

Last updated on 23 Jul 2012

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc