Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

Precondition

Precondition<A, B>: (value: A) => Result<A, B>

Precondition represents some condition that must be satisfied in order for data to be considered a valid type.

A Precondition accepts a value of type and returns an Either where the left side contains information about why the precondition failed or the right the resulting type and value.

Type parameters

  • A

  • B

Type declaration

Functions

Const and

Const caseOf

  • caseOf allows for the selective application of a precondition based on the type or structure of the value.

    Pattern matching works as follows: string -> Matches on the value of the string. number -> Matches on the value of the number. boolean -> Matches on the value of the boolean. object -> Each key of the object is matched on the value, all must match. function -> Treated as a constructor and results in an instanceof check. For String,Number and Boolean, this uses the typeof check.

    Type parameters

    • A

    • B

    Parameters

    Returns Precondition<A, B>

Const constant

  • constant forces the value to be the supplied value.

    Type parameters

    • A

    • B

    Parameters

    • b: B

    Returns Precondition<A, B>

Const discard

  • discard<A>(_: A): Either<Failure<A>, undefined>
  • discard throws away a value by assigning it ot undefined.

    Type parameters

    • A

    Parameters

    • _: A

    Returns Either<Failure<A>, undefined>

Const eq

  • eq tests if the value is equal (strictly) to the target.

    Type parameters

    • A

    • B

    Parameters

    • target: B

    Returns Precondition<A, B>

Const every

Const exists

  • exists requires the value to be enumerated in the supplied list.

    Type parameters

    • A

    Parameters

    • list: A[]

    Returns Precondition<A, A>

Const identity

  • identity<A>(value: A): Either<Failure<A>, A>
  • identity always succeeds with the value it is applied to.

    Type parameters

    • A

    Parameters

    • value: A

    Returns Either<Failure<A>, A>

Const isin

  • isin requires the value passed to be a member of a provided list.

    Type parameters

    • A

    Parameters

    • list: A[]

    Returns Precondition<A, A>

Const log

  • log<A>(value: A): Result<A, A>
  • log the value to the console.

    Type parameters

    • A

    Parameters

    • value: A

    Returns Result<A, A>

Const match

  • match preforms a type/structure matching on the input value in order to decide which precondition to apply.

    Preconditions must be wrapped in a 'caseOf' precondition.

    Type parameters

    • A

    • B

    Parameters

    Returns Precondition<A, B>

Const neq

  • neq tests if the value is not equal (strictly) to the target.

    Type parameters

    • A

    • B

    Parameters

    • target: B

    Returns Precondition<A, B>

Const notNull

  • notNull<A>(value: A): Result<A, A>
  • notNull will fail if the value is null or undefined.

    Type parameters

    • A

    Parameters

    • value: A

    Returns Result<A, A>

Const optional

  • optional applies the precondition given only if the value is not null or undefined.

    Type parameters

    • A

    • B

    Parameters

    Returns Precondition<A, A | B>

Const or

Const reject

  • reject always fails with reason no matter the value supplied.

    Type parameters

    • A

    • B

    Parameters

    • reason: string

    Returns Precondition<A, B>

Const when

  • when conditionally applies one of two preconditions depending on the outcome of a test function.

    Type parameters

    • A

    • B

    Parameters

    • test: (a: A) => boolean
        • (a: A): boolean
        • Parameters

          • a: A

          Returns boolean

    • applied: Precondition<A, B>
    • otherwise: Precondition<A, B>

    Returns Precondition<A, B>

Const whenFalse

Const whenTrue

  • whenTrue conditionally applies "applied" or "otherwise" depending on whether "condition" is true or not.

    Type parameters

    • A

    • B

    Parameters

    Returns Precondition<A, B>

Legend

  • Variable
  • Function
  • Function with type parameter
  • Type alias
  • Type alias with type parameter
  • Interface
  • Interface with type parameter
  • Class with type parameter

Generated using TypeDoc