New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

y-or-n

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

y-or-n

get y/n answer from user on terminal via callback

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
1
Created
Source

y-or-n

Get y/n from user on terminal in callback. That's it.

Usage

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.
})

Options

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

License

MIT. © 2016, Marinin Tim mt@marinin.xyz

Keywords

y-or-n

FAQs

Package last updated on 21 Jul 2016

Did you know?

Socket

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.

Install

Related posts