read
read(1) for node programs
Last updated a year ago by npm-cli-ops .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ npm install read 
SYNC missed versions from official npm registry.

read

For reading user input from stdin.

Similar to the readline builtin's question() method, but with a few more features.

Usage

const { read } = require('read')
// or with ESM: import { read } from 'read'
try {
  const result = await read(options)
} catch (er) {
  console.error(er)
}

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.
  • replace Replace silenced characters with the supplied character value.
  • timeout Number of ms to wait for user input before giving up.
  • default The default value if the user enters nothing.
  • edit Allow the user to edit the default value.
  • terminal Treat the output as a TTY, whether it is or not.
  • input Readable stream to get input data from. (default process.stdin)
  • output Writable stream to write prompts to. (default: process.stdout)
  • completer Autocomplete callback (see official api for details

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

Contributing

Patches welcome.

Current Tags

  • 4.0.0                                ...           latest (2 months ago)

18 Versions

  • 4.0.0                                ...           2 months ago
  • 3.0.1                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.1.0                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.0.7                                ...           9 years ago
  • 1.0.6                                ...           9 years ago
  • 1.0.5                                ...           11 years ago
  • 1.0.4                                ...           12 years ago
  • 1.0.3                                ...           12 years ago
  • 1.0.2                                ...           12 years ago
  • 1.0.1                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
  • 0.1.1                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
  • 0.0.3                                ...           12 years ago
  • 0.0.2                                ...           13 years ago
  • 0.0.1                                ...           13 years ago
Downloads
Total 10
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (11)

© 2010 - cnpmjs.org x YWFE | Home | YWFE