README.md
1## read
2
3For reading user input from stdin.
4
5Similar to the `readline` builtin's `question()` method, but with a
6few more features.
7
8## USAGE
9
10```javascript
11var read = require("read")
12read(options, callback)
13```
14
15The callback gets called with either the user input, or the default
16specified, or an error, as `callback(error, result, isDefault)`
17node style.
18
19## OPTIONS
20
21Every option is optional.
22
23* `prompt` What to write to stdout before reading input.
24* `silent` Don't echo the output as the user types it.
25* `replace` Replace silenced characters with the supplied character value.
26* `timeout` Number of ms to wait for user input before giving up.
27* `default` The default value if the user enters nothing.
28* `edit` Allow the user to edit the default value.
29* `terminal` Treat the output as a TTY, whether it is or not.
30* `input` Readable stream to get input data from. (default `process.stdin`)
31* `output` Writeable stream to write prompts to. (default: `process.stdout`)
32
33If silent is true, and the input is a TTY, then read will set raw
34mode, and read character by character.
35
36## COMPATIBILITY
37
38This module works sort of with node 0.6. It does not work with node
39versions less than 0.6. It is best on node 0.8.
40
41On node version 0.6, it will remove all listeners on the input
42stream's `data` and `keypress` events, because the readline module did
43not fully clean up after itself in that version of node, and did not
44make it possible to clean up after it in a way that has no potential
45for side effects.
46
47Additionally, some of the readline options (like `terminal`) will not
48function in versions of node before 0.8, because they were not
49implemented in the builtin readline module.
50
51## CONTRIBUTING
52
53Patches welcome.
54