Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Value

Provides a common interface to work with DOM elements of any Ion type.

Implementors should return null for any method that cannot provide the requested value.

Hierarchy

  • Value

Implemented by

Index

Methods

allFields

  • allFields(): [string, Value[]][]
  • Like the fields() method, but returns an array containing the field name/value pairs with all of the associated values to a field name, instead of field name/value pairs with just the last associated value to a field name. For example, for the following struct:

    {
        foo: 1,
        foo: null,
        foo: true,
    }

    a call to fields() would return a field name "foo" with a dom.Boolean representing true while a call to allFields() would return a field name "foo" with an Array of dom.Values: [1, null, true].

    Returns [string, Value[]][]

as

  • Allows for easy type casting from Value to a particular implementation of Value.

    If the Value is an instance of the type T represented by the provided constructor, this function will cast it as type T and return it; otherwise throws an Error.

    Type parameters

    Parameters

    Returns T

bigIntValue

  • bigIntValue(): JSBI | null
  • For the Integer type, returns a BigInt representation of the Value; otherwise throws an Error.

    Returns JSBI | null

booleanValue

  • booleanValue(): boolean | null
  • For the Boolean type, returns a JS boolean representation of the Value; otherwise throws an Error.

    Returns boolean | null

dateValue

  • dateValue(): Date | null
  • For the Timestamp type, returns a JS Date representation of the Value; otherwise throws an Error.

    Note that the conversion from an ion.Timestamp to a Date can involve a loss of precision. See timestampValue() for a lossless alternative.

    Returns Date | null

decimalValue

  • For the Decimal type, returns an ion.Decimal representation of the Value; otherwise throws an Error.

    Returns Decimal | null

deleteField

  • deleteField(name: string): boolean
  • For the Struct type, deletes the field with provided name if present. Returns a boolean indicating whether the Struct was modified. For all other types, throws an Error.

    Parameters

    • name: string

    Returns boolean

elements

  • For the Struct, List, and SExpression types, returns an array containing the container's nested values; otherwise throws an Error.

    Returns Value[]

equals

  • equals(other: any, options?: undefined | { epsilon?: number | null }): boolean
  • Compares this instance of dom.Value to the provided value and returns true if they are equal. If other is a dom.Value, this comparison checks for structural (or "non-strict") equivalence.

    Parameters

    • other: any

      other Ion Value or Js Object to be compared with this Ion Value.

    • Optional options: undefined | { epsilon?: number | null }

      options provided for equivalence as below epsilon used by Float for an equality with given epsilon precision. (Default: null)

    Returns boolean

fieldNames

  • fieldNames(): string[]
  • For the Struct type, returns an array containing the names of the fields in the Struct; otherwise throws an Error.

    Returns string[]

fields

  • fields(): [string, Value][]
  • For the Struct type, returns an array containing the field name/value pairs in the Struct; otherwise throws an Error.

    Returns [string, Value][]

get

  • Attempts to index into the Value with each pathElement in turn until:

    • The current Value is of a type that cannot be indexed into. (e.g. The current value is an Integer or Timestamp.)
    • A value is found that cannot use the current PathElement as an index. (e.g. The current Value is a List but the current PathElement is a string.)
    • An undefined value is encountered. (e.g. The current Value is a Struct and the current PathElement is a string,
        but the current PathElement is not a fieldName that exists in the Struct.)
    • The pathElements are exhausted and the requested Value is discovered.

    Parameters

    • Rest ...pathElements: PathElement[]

      One or more values to be used to index into the Value.

    Returns Value | null

    null if no value is found at the specified path. Otherwise, returns the discovered Value.

getAll

  • Like the get(PathElement[]) method, but returns all of the values associated with a given field name instead of just the last one. For example, for the following struct:

    {
        foo: 1,
        foo: null,
        foo: true,
    }

    a call to get("foo") would return a dom.Boolean representing true while a call to getAll("foo") would return an Array of dom.Values: [1, null, true].

    Parameters

    Returns Value[] | null

    null if no value is found at the specified path. Otherwise, returns the discovered Value.

getAnnotations

  • getAnnotations(): string[]
  • Returns an array containing any annotations associated with this value. If this value does not have any annotations, an empty array will be returned.

    Returns string[]

getType

ionEquals

  • ionEquals(other: any, options?: undefined | { epsilon?: number | null; ignoreAnnotations?: undefined | false | true; ignoreTimestampPrecision?: undefined | false | true }): boolean
  • For checking equivalence of an Ion Values represented by dom.Value with the other value represented by dom.Value.

    Strict equivalence refers to Ion data model equivalence as defined in Ion Equivalence[1] and by Ion Specification[2]

    Structural or non-strict equivalence follows the same rules as strict equivalence, except that

    1. Annotations are not considered, and
    2. Timestamps that represent the same instant in time are always considered equivalent.

    [1] https://www.javadoc.io/doc/com.amazon.ion/ion-java/latest/com/amazon/ion/util/Equivalence.html [2] http://amzn.github.io/ion-docs/docs/spec.html

    Parameters

    • other: any

      other Ion Value to be compared with this Ion Value.

    • Optional options: undefined | { epsilon?: number | null; ignoreAnnotations?: undefined | false | true; ignoreTimestampPrecision?: undefined | false | true }

      options provided for equivalence as below epsilon used by Float for an equality with given epsilon precision. (Default: null) ignoreAnnotations specifies whether to ignore annotations or not for equality. (Default: false) ignoreTimestampPrecision specifies whether to ignore timestamp local offset and precision or not for equality. (Default: false)

    Returns boolean

isNull

  • isNull(): boolean
  • Returns true if this Value is a Null and false otherwise.

    Returns boolean

numberValue

  • numberValue(): number | null
  • For the Integer, Float, and Decimal types, returns a JS number representation of the Value; otherwise throws an Error.

    In some cases, this method will perform conversions that inherently involve loss of precision. See bigIntValue() and decimalValue() for lossless alternatives.

    Returns number | null

stringValue

  • stringValue(): string | null
  • For the String and Symbol types, returns a JS string representation of the Value's text; otherwise throws an Error.

    Returns string | null

timestampValue

  • For the Timestamp type, returns an ion.Timestamp representation of the Value; otherwise throws an Error.

    Returns Timestamp | null

uInt8ArrayValue

  • uInt8ArrayValue(): Uint8Array | null
  • For the Blob and Clob types, returns a Uint8Array representation of the Value's bytes; otherwise throws an Error.

    Returns Uint8Array | null

writeTo

  • writeTo(writer: Writer): void
  • Writes the Ion value represented by this dom.Value (including annotations) to the provided Writer. If the value is a container, writeTo() will be called recursively on its nested values.

    Parameters

    • writer: Writer

      An Ion Writer to which the value should be written.

    Returns void