Class Form<T, U>Abstract

Transformation between a structurally typed [Item] and a nominally typed JavaScript object.

Type Parameters

  • T

  • U = T

Hierarchy

  • Form

Constructors

  • Type Parameters

    • T

    • U = T

    Returns Form<T, U>

Properties

tag: string

Returns the key of the tag attribute that distinguishes structures of this Form; returns undefined if this Form has no distinguishing tag attribute. Used to accelerate discrimination of polymorphic structural types with nominal type hints.

unit: T

Returns a default–possibly undefined–value of type T. Used as the fallback return value when [Item.coerce coercing] an invalid structural value.

Methods

  • Converts a structurally typed item into a nominally typed JavaScript object, optionally based on the provided prototype object.

    Parameters

    • item: Item
    • Optional object: T

    Returns T

  • Converts a nominally typed JavaScript object into its structurally typed equivalent, optionally based on the provided prototype item.

    Parameters

    • object: T | U
    • Optional item: Item

    Returns Item

  • Returns a version of this Form that requires a head [Attr] with the given tag name.

    Parameters

    • tag: string

    Returns Form<T, U>

  • Returns a version of this Form with the given unit value.

    Parameters

    • unit: T

    Returns Form<T, U>

  • Returns Form<boolean, boolean>

  • Returns Form<number, number>

  • Returns Form<string, string>

Generated using TypeDoc