bungibindies

Values

pub fn confirm(message: String) -> Bool

Bun has a global confirm function similar to the browser’s window.confirm.

Returns True if the user clicked “OK”, False if the user clicked “Cancel” or the confirm could not be displayed. It does NOT return a Result because there is no way to distinguish between the user clicking “Cancel” and the confirm not being displayed.

pub fn main() -> Result(String, Nil)
pub fn prompt(
  message msg: String,
  or default: String,
) -> Result(String, Nil)

Bun has a global prompt function similar to the browser’s window.prompt.

Returns Ok(String) if the user entered something, Error(Nil) if the prompt could not be displayed or the user cancelled it. The default parameter is the default text to display in the prompt input field and also the text that will be returned if the user submits the prompt without entering anything.

pub fn runs_in_bun() -> Result(Nil, Nil)

Check if running in the Bun runtime. Returns Ok(Nil) if running in Bun, Error(Nil) otherwise.

This is useful for libraries that want to use Bun-specific features when available, but still work in other JavaScript runtimes like Node.js or Deno.

Search Document