Last active
December 5, 2022 23:38
-
-
Save Densyakun/11eb9ae66bdee6fd6e39a7dbad50f8ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createInterface } from "readline" | |
import { promisify } from "util" | |
const rl = createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}) | |
const question = promisify<string, string>(rl.question as (answer: string) => Promise<string>).bind(rl) | |
async function questionAndAnswer() { | |
// Wait to receive data on the input stream. | |
let answer = "" | |
while (answer !== "y" && answer !== "n") { | |
answer = (await question('(Y/N)? ')) | |
if (answer.length) answer = answer[0].toLowerCase() | |
} | |
if (answer === "y") { | |
// | |
} else if (answer === "n") { | |
// | |
} | |
rl.close() | |
} | |
questionAndAnswer() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment