Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IImmutable<T>

The interface for a primitive value. The actual value can always be retrieved by doing primitive.value but all primitives implement the Symbol.toPrimitive interface so are naturally convertible to string and number.

Type parameters

  • T

Hierarchy

Index

Properties

value

value: T

The actual primitive value

Methods

__@toPrimitive

  • __@toPrimitive(hint: "string" | "number" | "default"): string | number
  • Converts the object into a primitive

    Parameters

    • hint: "string" | "number" | "default"

    Returns string | number

__@toStringTag

  • __@toStringTag(): string

toJSON

  • toJSON(key: string): any | number | string | boolean | null
  • Converts the primitive into it's JSON representation

    Parameters

    • key: string

      Will be one of:

      • if this object is a property value, the property name
      • if it is in an array, the index in the array, as a string
      • an empty string if JSON.stringify() was directly called on this object

    Returns any | number | string | boolean | null

    the object to serialize with JSON.stringify

toString

  • toString(): string
  • Converts the primitive into it's string representation. Often has a unit value associated with it such as 125ms

    Returns string

valueOf

  • valueOf(): string | number
  • Primitives must implement the legacy valueOf interface. Usually just forwards to the newer Symbol.toPrimitive API

    Returns string | number