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

x/eitherway/lib/core/result.ts>Result.from

Yet Another Option and Result Implementation - providing safe abstractions for fallible flows inspired by F# and Rust
Latest
function Result.from
import { Result } from "https://deno.land/x/eitherway@0.10.0/lib/core/result.ts";
const { from } = Result;

Use this to lift the result of an infallible function into a Result context.

In case, the supplied function panics, an exception is thrown, wrapping the original exception.

Examples

Example 1

import { assert } from "./assert.ts";
import { Err, Ok, Result } from "./mod.ts";

const produceArr = () => [1,2,3];
const res = Result.from(produceArr);

assert(res.isOk());

Parameters

fn: () => T