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

read

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

LICENCE

10

example/example.js

@@ -6,8 +6,10 @@ var read = require("../lib/read.js")

read({prompt: "Enter 4 characters: ", num: 4 }, function (er, four) {
console.error(user + ":" + pass + " " + JSON.stringify(four))
console.error("If the program doesn't end right now,\n"
+"then you may be experiencing this bug:\n"
+"https://github.com/joyent/node/issues/2257")
read({prompt: "Password again: ", default: "test-pass", silent: true }, function (er, pass2) {
console.error(user + ":" + pass + " (" + pass2 + ") " + JSON.stringify(four) + (pass === pass2))
console.error("If the program doesn't end right now,\n"
+"then you may be experiencing this bug:\n"
+"https://github.com/joyent/node/issues/2257")
})
})
})
})

16

lib/read.js

@@ -8,2 +8,10 @@

function raw (mode) {
try {
process.stdin.setRawMode(mode)
} catch (e) {
tty.setRawMode(mode)
}
}
function read (opts, cb) {

@@ -29,3 +37,3 @@ if (!cb) cb = opts, opts = {}

var t = setTimeout(function () {
tty.setRawMode(false)
raw(false)
process.stdout.write("\n")

@@ -114,3 +122,3 @@ if (def) done(null, def)

tty.setRawMode(true)
raw(true)
stdin.resume()

@@ -128,3 +136,3 @@ stdin.on("error", cb)

case delim:
tty.setRawMode(false)
raw(false)
stdin.removeListener("data", D)

@@ -138,3 +146,3 @@ stdin.removeListener("error", cb)

case "\u0003": case "\0": // ^C or other signal abort
tty.setRawMode(false)
raw(false)
stdin.removeListener("data", D)

@@ -141,0 +149,0 @@ stdin.removeListener("error", cb)

{
"name": "read",
"version": "0.0.1",
"version": "0.0.2",
"main": "lib/read.js",

@@ -15,3 +15,4 @@ "dependencies": {},

"url": "git://github.com/isaacs/read.git"
}
},
"license":"BSD"
}

@@ -23,2 +23,3 @@ For reading user input from stdin.

* `timeout` Number of ms to wait for user input before giving up.
* `default` The default value if the user enters nothing.

@@ -35,1 +36,10 @@ If silent is true, or num is set, or delim is something other than

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>
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