import { Some } from "https://deno.land/x/eitherway@0.10.0/lib/core/option.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
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);