Init
This commit is contained in:
22
utility/readPromise.js
Normal file
22
utility/readPromise.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const rd = require('readline').createInterface(process.stdin,process.stdout)
|
||||
|
||||
|
||||
/**
|
||||
* Get an answer from a reply
|
||||
* @param {String} askQuestion
|
||||
* @returns {Promise<String>}
|
||||
*/
|
||||
module.exports.ask = (askQuestion)=>{
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
return new Promise((resolve,reject)=>{
|
||||
rd.question(askQuestion,answer=>{
|
||||
if(answer){
|
||||
resolve(answer)
|
||||
}
|
||||
// else{
|
||||
// reject(new Error("REE NO ANSWER"))
|
||||
// }
|
||||
})
|
||||
})
|
||||
}
|
||||
module.exports.close = ()=>(rd.close())
|
Reference in New Issue
Block a user