Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/eitherway/lib/core/mod.ts>Some.empty

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

Use this to signal some kind of success irrespective of the wrapped type as alternative to Some<void>

Seldom useful in a pure Option<T> context, mostly provided for compatibility with Result<T, E>, where using Ok<void> to signal a successful operation would evaluate to None, if converted into an Option<T>

Examples

Example 1

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

function doStuff(): Option<Empty> {
  return Some.empty();
}

const res = doStuff()
  .okOrElse(() => TypeError("Invalid")) // conversion to Result
  .ok(); //convert back to Some<Empty>

assert(res.isSome() === true);