Remove console.logs.

This commit is contained in:
2021-04-29 18:43:53 -07:00
parent c1935e58be
commit e037190c7f
4 changed files with 59 additions and 29 deletions

28
User.ts Normal file
View File

@ -0,0 +1,28 @@
const DEFAULT_PROMPT = ">";
export default class User {
#prompt: string;
#out: (text: string) => Promise<void>;
constructor() {
this.#prompt = DEFAULT_PROMPT;
this.#out = async (text: string) => {
const data = new TextEncoder().encode(text);
await Deno.stdout.write(data);
};
}
ask(question: string): string {
const answer = prompt(`${question}\n${this.#prompt} `);
if (!answer) {
return "";
}
return answer;
}
async tell(statement: string): Promise<void> {
await this.#out(`\n${statement}\n`);
}
}