Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/ahh/src/option/mod.ts>O.okOr

Idiomatic type-safety structures for TypeScript.
Go to Latest
method O.okOr
import { O } from "https://deno.land/x/ahh@v0.10.0/src/option/mod.ts";

Converts opt into an Ok if it is a Some.

Examples

import { O, None } from "./mod.ts";

console.log(O.okOr(1, Error())); // 1
console.log(O.okOr(None, Error())); // Error()

Type Parameters

T
E extends Error

Parameters

opt: Option<T>
err: E