Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface DocumentType<T>

Type parameters

  • T

Hierarchy

Index

Properties

Optional changeCase

changeCase: CaseStyle

The keys of the serialized documents are renamed following the supplied style (undefined to keep the original name).

Optional name

name: undefined | string

Name of this type. This is only used to help with debugging.

Optional noExtraKeys

noExtraKeys: undefined | false | true

Treat values with extra keys as invalid.

properties

properties: object

A dictionary between a property name and its description.

Type declaration

Optional rename

rename: undefined | object

Methods

clone

  • clone(value: T): T
  • Returns a deep copy of value.

    Parameters

    • value: T

      The value to clone, trusted to be compatible with this type.

    Returns T

    A deep copy of the supplied value, restricted to the properties of this type.

diff

  • diff(oldVal: T, newVal: T): Diff<T> | undefined
  • Returns undefined if both values are equivalent, otherwise a diff representing the change from oldVal to newVal.

    Parameters

    • oldVal: T

      The old value

    • newVal: T

      The new value

    Returns Diff<T> | undefined

equals

  • equals(left: T, right: T): boolean
  • Tests if left is equal to value.

    This is a deep strict structural equality test restricted to the properties of this type.

    It satisfies the following properties (the variables a, b and c are valid values):

    • Reflexivity: type.equal(a, a) === true
    • Symmetry: type.equals(a, b) === type.equals(b, a)
    • Transitivity: if type.equals(a, b) && type.equals(b, c) then type.equals(a, c)

    The above properties mean that type objects implement the Setoid algebra as specified by Static Land.

    see

    https://github.com/rpominov/static-land/blob/master/docs/spec.md#setoid

    Parameters

    • left: T

      Left value, trusted to be compatible with this type.

    • right: T

      Right value, trusted to be compatible with this type.

    Returns boolean

    Boolean indicating if both values are equal.

getOutKey

  • getOutKey(key: keyof T): string

Optional lte

  • lte(left: T, right: T): boolean
  • Compares two valid values.

    Parameters

    • left: T

      Left operand, a valid value.

    • right: T

      Right operand, a valid value.

    Returns boolean

    Boolean indicating if left <= right is true.

patch

  • patch(oldVal: T, diff: Diff<T> | undefined): T

Optional read

  • read<R>(reader: Reader<R>, input: R): T
  • Deserializes a value of this type.

    Type parameters

    • R

    Parameters

    • reader: Reader<R>

      Reader to drive during the deserialization.

    • input: R

      Reader input.

    Returns T

    Valid value.

reverseDiff

  • reverseDiff(diff: Diff<T> | undefined): Diff<T> | undefined

squash

  • squash(oldDiff: Diff<T> | undefined, newDiff: Diff<T> | undefined): Diff<T> | undefined

test

  • test(value: T): boolean
  • Tests if this type matches value.

    Parameters

    • value: T

      The value to test against this type.

    Returns boolean

    Boolean indicating if this type matches value.

Optional testError

  • testError(value: T): Error | undefined
  • Tests if this type matches value, describes the error if not.

    Parameters

    • value: T

      The value to test against this type.

    Returns Error | undefined

    If this type matches value then undefined; otherwise an error describing why this type does not match value.

Optional write

  • write<W>(writer: Writer<W>, value: T): W
  • Serializes the valid value value.

    Type parameters

    • W

    Parameters

    • writer: Writer<W>

      Writer used to emit the data.

    • value: T

      Value to serialize.

    Returns W

    Writer result.

Generated using TypeDoc