Skip to main content
Module

x/eitherway/mod.ts>Option.from

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

Alias for Option()

Examples

Example 1

import { assert } from "./assert.ts";
import { Option, None, Some } from "./option.ts";

const str: string | undefined = "thing";
const undef: string | undefined = undefined;

const some: Option<string> = Option.from(str);
const none: Option<string> = Option.from(undef);

assert(some instanceof Option === true);
assert(none instanceof Option === true);
assert(some.isSome() === true);
assert(none.isNone() === true);