1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 04:52:26 -05:00

docs: JSDocs examples for prompt, confirm, and alert (#27695)

Adds examples
This commit is contained in:
Phil Hawksworth 2025-01-16 06:20:45 -08:00 committed by GitHub
parent e54d467812
commit 8d2f76ae36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -226,6 +226,12 @@ declare var navigator: Navigator;
*
* If the stdin is not interactive, it does nothing.
*
* @example
* ```ts
* // Displays the message "Acknowledge me! [Enter]" and waits for the enter key to be pressed before continuing.
* alert("Acknowledge me!");
* ```
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/alert
* @category Platform
*
* @param message
@ -239,6 +245,15 @@ declare function alert(message?: string): void;
*
* If the stdin is not interactive, it returns false.
*
* @example
* ```ts
* const shouldProceed = confirm("Do you want to proceed?");
*
* // If the user presses 'y' or 'Y', the result will be true
* // If the user presses 'n' or 'N', the result will be false
* console.log("Should proceed?", shouldProceed);
* ```
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm
* @category Platform
*
* @param message
@ -256,6 +271,15 @@ declare function confirm(message?: string): boolean;
*
* If the stdin is not interactive, it returns null.
*
* @example
* ```ts
* const pet = prompt("Cats or dogs?", "It's fine to love both!");
*
* // Displays the user's input or the default value of "It's fine to love both!"
* console.log("Best pet:", pet);
* ```
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt
*
* @category Platform
*
* @param message