Commit to Deno project.
This commit is contained in:
19
console.ts
Normal file
19
console.ts
Normal file
@ -0,0 +1,19 @@
|
||||
const DEFAULT_PROMPT = ">";
|
||||
|
||||
export default class Console {
|
||||
#prompt: string;
|
||||
|
||||
constructor() {
|
||||
this.#prompt = DEFAULT_PROMPT;
|
||||
}
|
||||
|
||||
ask(question: string): string {
|
||||
const answer = prompt(`${question}\n${this.#prompt} `);
|
||||
|
||||
if (!answer) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user