npm package to take command line inputs with Promise return
$ npm i inputsync
Include npm Package inputsync
in you JS file
const InputSync = require("inputsync");
To take command line input
const name = await InputSync.getline("Your Name : ")
console.log( "Your name is : " + name )
//best practice with error handling
try{
const name_withoutErr = await InputSync.getline("Your Name : ")
//if no error in line above
console.log( "Your name is : " + name_withoutErr )
}catch(e){
console.error(e)
}
InputSync.getline("Your favorite city : ").then( (input) => {
console.log( "Your favorite city : " + input )
}, (err) => {
console.error(err) //incase error is returned
})
InputSync.getline(question)
question
string
Returns Promise
Email me at : [email protected]
Subject : Contribute to npm package inputsync
Body : Describe why & how would you like you contribute