Skip to main content
Module

x/eitherway/lib/core/option.ts

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

Namespaces

Utility functions to work with Option<T>[]

Functions

Use this to apply an Option<T> to a handler of type Option<MapFn>

Alias for Option()

Use this if all falsy values should be evaluated to None

Use this if instances of Error should be evaluated to None

Use this to return the provided instance of Option<T> Mostly usefull for flattening or en lieu of a no-op

Use this to compose functions and Option constructors

Same as Option.lift but with a safety net.

Type predicate - use this to check if all values in an array are None

Type predicate - use this to check if all values in an array are Some<T>

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

Interfaces

The base interface implemented by Some and None

Type Aliases

Use this to infer an Option<T> type

Use this to infer the encapsulated Some<T> types from a tuple of Option<T>

Use this to infer the encapsulated <T> type from a Some<T>

Use this to infer a union of all Some<T> types from a tuple of Option<T>

None

None represents the absence of a value and is the opinionated, composable equivalent of undefined.

Option

Option<T> represents:

  • EITHER the encapsulation of a value of type <T> via Some<T>
  • OR the absence of a value via None

Some