pax_global_header00006660000000000000000000000064125674242500014521gustar00rootroot0000000000000052 comment=b14516b9236c40140fd0666567f5d0c588a09a62 read-1.0.7/000077500000000000000000000000001256742425000124415ustar00rootroot00000000000000read-1.0.7/.gitignore000066400000000000000000000000331256742425000144250ustar00rootroot00000000000000npm-debug.log node_modules read-1.0.7/.travis.yml000066400000000000000000000002061256742425000145500ustar00rootroot00000000000000language: node_js language: node_js node_js: - '0.8' - '0.10' - '0.12' - 'iojs' before_install: - npm install -g npm@latest read-1.0.7/LICENSE000066400000000000000000000013751256742425000134540ustar00rootroot00000000000000The ISC License Copyright (c) Isaac Z. Schlueter and Contributors Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. read-1.0.7/README.md000066400000000000000000000032711256742425000137230ustar00rootroot00000000000000## read For reading user input from stdin. Similar to the `readline` builtin's `question()` method, but with a few more features. ## USAGE ```javascript var read = require("read") read(options, callback) ``` The callback gets called with either the user input, or the default specified, or an error, as `callback(error, result, isDefault)` 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. * `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` Writeable stream to write prompts to. (default: `process.stdout`) If silent is true, and the input is a TTY, then read will set raw mode, and read character by character. ## COMPATIBILITY This module works sort of with node 0.6. It does not work with node versions less than 0.6. It is best on node 0.8. On node version 0.6, it will remove all listeners on the input stream's `data` and `keypress` events, because the readline module did not fully clean up after itself in that version of node, and did not make it possible to clean up after it in a way that has no potential for side effects. Additionally, some of the readline options (like `terminal`) will not function in versions of node before 0.8, because they were not implemented in the builtin readline module. ## CONTRIBUTING Patches welcome. read-1.0.7/example/000077500000000000000000000000001256742425000140745ustar00rootroot00000000000000read-1.0.7/example/example.js000066400000000000000000000010101256742425000160550ustar00rootroot00000000000000var read = require("../lib/read.js") read({prompt: "Username: ", default: "test-user" }, function (er, user) { read({prompt: "Password: ", default: "test-pass", silent: true }, function (er, pass) { read({prompt: "Password again: ", default: "test-pass", silent: true }, function (er, pass2) { console.error({user: user, pass: pass, verify: pass2, passMatch: (pass === pass2)}) console.error("the program should exit now") }) }) }) read-1.0.7/lib/000077500000000000000000000000001256742425000132075ustar00rootroot00000000000000read-1.0.7/lib/read.js000066400000000000000000000045771256742425000144750ustar00rootroot00000000000000 module.exports = read var readline = require('readline') var Mute = require('mute-stream') function read (opts, cb) { if (opts.num) { throw new Error('read() no longer accepts a char number limit') } if (typeof opts.default !== 'undefined' && typeof opts.default !== 'string' && typeof opts.default !== 'number') { throw new Error('default value must be string or number') } var input = opts.input || process.stdin var output = opts.output || process.stdout var prompt = (opts.prompt || '').trim() + ' ' var silent = opts.silent var editDef = false var timeout = opts.timeout var def = opts.default || '' if (def) { if (silent) { prompt += '(