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

x/ahh/src/result/mod.ts>fn

Opinionated idiomatic type-safety functions.
Go to Latest
function fn
import { fn } from "https://deno.land/x/ahh@v0.11.0/src/result/mod.ts";

Calls f and returns the result as an Ok, or returns an Err if it throws.

Examples

Example 1

import { default as R } from "./mod.ts";

console.log(R.fn(() => 1)); // 1
console.log(R.fn(() => { throw Error(); })); // Error()

Type Parameters

T
E extends Error

Parameters

f: () => T