Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Form<T, U>

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

Type parameters

  • T: U

  • U

Hierarchy

  • Form

Index

Methods

Abstract cast

  • cast(item: Item, object?: T): T | undefined
  • 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 | undefined

Abstract mold

  • mold(object: U, item?: Item): Item
  • Converts a nominally typed JavaScript object into its structurally typed equivalent, optionally based on the provided prototype item.

    Parameters

    • object: U
    • Optional item: Item

    Returns Item

tag

  • tag(): string | undefined
  • tag(tag: string | undefined): Form<T, U>
  • 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 distrcrimination of polymorphic structural types with nominal type hints.

    Returns string | undefined

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

    Parameters

    • tag: string | undefined

    Returns Form<T, U>

unit

  • unit(): T | undefined
  • unit(unit: T | undefined): Form<T, U>

Static forAny

Static forBoolean

  • forBoolean(): Form<boolean>

Static forItem

Static forNumber

  • forNumber(): Form<number>

Static forString

  • forString(): Form<string>

Static forValue