Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including wait-for-user-input with all npm packages installed. Try it out:

var waitForUserInput = require("wait-for-user-input")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

wait-for-user-input v1.0.0

minimal way to wait for user input on the terminal.

wait-for-user-input

NPM

minimal way to wait for user input on the terminal.

handles single character user input. (y/n)

async main () {
  const input = await waitForUserInput('do you agree?')
  ...
}

installation

npm i wait-for-user-input

usage

async / await

const waitForUserInput = require('wait-for-user-input')

main()

async function main () {
  const userInput = await waitForUserInput('')
  // handle user input
}

promises

const waitForUserInput = require('wait-for-user-input')

waitForUserInput('')
.then(userInput => {
  // handle user input
})
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free