Prompt user for text input with automatic cleanup.
Behavior: Create readline interface, display prompt, await input, trim whitespace, cleanup interface. Blocks until user responds.
Error Handling: Throws TypeError for non-string prompts. Readline errors propagated to caller.
Prompt text displayed to user
Trimmed user input
Question parameter must be string
const name = await ask('Name: ');const email = await ask('Email: ');if (!email.includes('@')) throw new Error('Invalid email'); Copy
const name = await ask('Name: ');const email = await ask('Email: ');if (!email.includes('@')) throw new Error('Invalid email');
Prompt user for text input with automatic cleanup.
Behavior: Create readline interface, display prompt, await input, trim whitespace, cleanup interface. Blocks until user responds.
Error Handling: Throws TypeError for non-string prompts. Readline errors propagated to caller.