Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/dialog.ts>prompt

A JavaScript extension package for building strong and modern applications.
Latest
function prompt
import { prompt } from "https://deno.land/x/ayonli_jsext@v0.9.72/dialog.ts";

Displays a dialog with a message prompting the user to input some text, and to wait until the user either submits the text or cancels the dialog.

Examples

Example 1

import { prompt } from "@ayonli/jsext/dialog";

const name = await prompt("What's your name?");

if (name) {
    console.log(`Hello, ${name}!`);
}

Example 2

// with default value
import { prompt } from "@ayonli/jsext/dialog";

const name = await prompt("What's your name?", "John Doe");

if (name) {
    console.log(`Hello, ${name}!`);
}

Parameters

message: string
optional
defaultValue: string | undefined

Returns

Promise<string | null>

Examples

Example 1

// input password
import { prompt } from "@ayonli/jsext/dialog";

const password = await prompt("Enter your password:", { type: "password" });

if (password) {
    console.log("Your password is:", password);
}

Parameters

message: string
optional
options: PromptOptions

Returns

Promise<string | null>