
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
Get y/n from user on terminal in callback. That's it.
Install it from npm via npm i y-or-n. After that, you're ready to go:
const yorn = require('y-or-n')
yorn('Is it dark?', function(err, answer) {
// answer is Boolean, true || false.
})
y-or-n supports few options that you can pass as a second argument. Default values:
const yorn = require('y-or-n')
yorn('Are you OK? y/n', {
timeout: 0, // ms, 0 means no timeout
defaultAnswer: false, // read section below
input: process.stdin, // Readable stream
output: process.stdout, // Writable stream
strictNn: false // accept only n or N as false answer
}, function getAnswer (err, answer) {
if (err) {
// if user didn't enter anything before timeout
// then err.code is ETIMEOUT
assert(err.code === 'ETIMEOUT')
// and we probably should react somehow anyway, answer
// is defaultAnswer from options object
}
})
### opts.defaultAnswer
Value that is used in few cases, namely when timeout is set and expired, when strictNn is set and input is not any of [yYnN].
MIT. © 2016, Marinin Tim mt@marinin.xyz
FAQs
get y/n answer from user on terminal via callback
We found that y-or-n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.