Skip to main content
Module

x/ahh/option.ts>Option

Mostly rusty stuff for @denoland.
Go to Latest
interface Option
import { type Option } from "https://deno.land/x/ahh@v0.5.1/option.ts";

Represents an optional value that either exists (Some) or does not exist (None).

Methods

isSome(): boolean

Returns true if the Option is Some.

isNone(): boolean

Returns true if the Option is None.

contains<U extends T>(value: U): boolean

Returns true of the Option is a Some containing value.

expect(message: string): T

Returns the contained Some value.

Throws if the Option is a None with the provided message.

unwrap(): T

Returns the contained Some value.

Throws if the Option is a None.

map<U>(fn: ((_: T) => U)): Option<U>

Returns a new Option where the value is mapped with fn.

and<U>(other: Option<U>): Option<U>

Returns other if this and other are Some.

or(other: Option<T>): Option<T>

Returns this or other if either is Some.

xor(other: Option<T>): Option<T>

Returns this or other if only one is Some.