Options
All
  • Public
  • Public/Protected
  • All
Menu

Provides common conversion and validation logic needed to instantiate subclasses of dom.Value from a given Javascript value of unknown type (any) and an optional annotations array.

Given a Javascript value, will test its type to see whether it is:

  1. A primitive that is supported by the specified constructor.
  2. A boxed primitive that is supported by the specified constructor if unboxed via valueOf().
  3. A class that is supported by the specified constructor as-is, including boxed primitives.

If the value matches any of the above descriptions, the provided constructor will be invoked with the value; otherwise, throws an Error.

Constructors are expected to be compatible with the signature:

 constructor(value, annotations: string[]): ClassName

See also: Value._fromJsValue()

Hierarchy

  • FromJsConstructor

Index

Constructors

Methods

Constructors

constructor

  • Constructor.

    Parameters

    • _primitives: Set<string>

      Primitive types that will be passed through as-is.

    • _classesToUnbox: Set<Constructor<{}>>

      Boxed primitive types that will be converted to primitives via valueOf() and then passed through.

    • _classes: Set<Constructor<{}>>

      Classes that will be passed through as-is.

    Returns FromJsConstructor

Methods

construct

  • construct(constructor: any, jsValue: any, annotations?: string[]): Value
  • Invokes the provided constructor if jsValue is of a supported data type; otherwise throws an Error.

    Parameters

    • constructor: any

      A dom.Value subclass's constructor to call.

    • jsValue: any

      A Javascript value to validate/unbox before passing through to the constructor.

    • annotations: string[] = []

      An optional array of strings to associate with the newly constructed dom.Value.

    Returns Value