Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Struct

Represents a struct[1] value in an Ion stream.

Struct fields can be accessed as properties on this object. For example:

let s: any = ion.load('{foo: 1, bar: 2, baz: qux::3}'); assert.equal(6, s.foo + s['bar'] + s.baz);

If a field in the struct has the same name as a method on the Struct class, attempting to access that property will always resolve to the method.

let s: any = ion.load('{fieldNames: ["foo", "bar", "baz"]}'); // Conflicts with Struct#fieldNames()
assert.deepEqual(s.fieldNames, ["foo", "bar", "baz"]); // Fails; `s.fieldNames` is a method
assert.deepEqual(s.fieldNames(), ["fieldNames"]); // Passes

Unlike direct property accesses, Struct's get() method will only resolve to fields.

let s: any = ion.load('{fieldNames: ["foo", "bar", "baz"]}'); // Conflicts with Struct#fieldNames()
assert.equal(s.get('fieldNames', 0).stringValue(), "foo"); // Passes

[1] http://amzn.github.io/ion-docs/docs/spec.html#struct

Hierarchy

  • newClass<ObjectConstructor, this> & Object
    • Struct

Implements

Index

Constructors

constructor

  • new Struct(fields: Iterable<[string, Value]> | Iterable<[string, Value[]]>, annotations?: string[]): Struct
  • Constructor.

    Parameters

    • fields: Iterable<[string, Value]> | Iterable<[string, Value[]]>

      An iterator of field name/value pairs to represent as a struct.

    • Default value annotations: string[] = []

      An optional array of strings to associate with this null value.

    Returns Struct

Properties

_ionAnnotations

_ionAnnotations: string[]

_ionType

_ionType: IonType

should

should: Assertion

Static Object

Object: ObjectConstructor

Provides functionality common to all JavaScript objects.

Methods

[Symbol.iterator]

  • [Symbol.iterator](): IterableIterator<[string, Value]>

_ionValueEquals

  • _ionValueEquals(child: Value[], expectedChild: Value[], options: any): boolean

_setAnnotations

  • _setAnnotations(annotations: string[]): void

_unsupportedOperation

  • _unsupportedOperation<T>(functionName: string): never

_valueEquals

  • _valueEquals(other: any, options?: { epsilon?: number | null; ignoreAnnotations?: undefined | false | true; ignoreTimestampPrecision?: undefined | false | true; onlyCompareIon?: undefined | false | true }): boolean
  • Parameters

    • other: any
    • Default value options: { epsilon?: number | null; ignoreAnnotations?: undefined | false | true; ignoreTimestampPrecision?: undefined | false | true; onlyCompareIon?: undefined | false | true } = {epsilon: null,ignoreAnnotations: false,ignoreTimestampPrecision: false,onlyCompareIon: true,}
      • Optional epsilon?: number | null
      • Optional ignoreAnnotations?: undefined | false | true
      • Optional ignoreTimestampPrecision?: undefined | false | true
      • Optional onlyCompareIon?: undefined | false | true

    Returns boolean

allFields

  • allFields(): [string, Value[]][]

as

bigIntValue

  • bigIntValue(): JSBI | null

booleanValue

  • booleanValue(): boolean | null

dateValue

  • dateValue(): Date | null

decimalValue

deleteField

  • deleteField(name: string): boolean

elements

equals

  • equals(other: any, options?: { epsilon?: number | null }): boolean
  • Implementation of the dom.Value interface method equals()

    Parameters

    • other: any
    • Default value options: { epsilon?: number | null } = { epsilon: null }
      • Optional epsilon?: number | null

    Returns boolean

fieldNames

  • fieldNames(): string[]

fields

  • fields(): [string, Value][]

get

getAll

getAnnotations

  • getAnnotations(): string[]

getType

hasOwnProperty

  • hasOwnProperty(v: PropertyKey): boolean
  • Determines whether an object has a property with the specified name.

    Parameters

    • v: PropertyKey

      A property name.

    Returns boolean

ionEquals

  • ionEquals(other: Value, options?: { epsilon?: number | null; ignoreAnnotations?: undefined | false | true; ignoreTimestampPrecision?: undefined | false | true }): boolean
  • Implementation of the dom.Value interface method ionEquals()

    Parameters

    • other: Value
    • Default value options: { epsilon?: number | null; ignoreAnnotations?: undefined | false | true; ignoreTimestampPrecision?: undefined | false | true } = {epsilon: null,ignoreAnnotations: false,ignoreTimestampPrecision: false,}
      • Optional epsilon?: number | null
      • Optional ignoreAnnotations?: undefined | false | true
      • Optional ignoreTimestampPrecision?: undefined | false | true

    Returns boolean

isNull

  • isNull(): boolean

isPrototypeOf

  • isPrototypeOf(v: Object): boolean
  • Determines whether an object exists in another object's prototype chain.

    Parameters

    • v: Object

      Another object whose prototype chain is to be checked.

    Returns boolean

numberValue

  • numberValue(): number | null

propertyIsEnumerable

  • propertyIsEnumerable(v: PropertyKey): boolean
  • Determines whether a specified property is enumerable.

    Parameters

    • v: PropertyKey

      A property name.

    Returns boolean

stringValue

  • stringValue(): string | null

timestampValue

toJSON

  • toJSON(): any

toLocaleString

  • toLocaleString(): string
  • Returns a date converted to a string using the current locale.

    Returns string

toString

  • toString(): string

uInt8ArrayValue

  • uInt8ArrayValue(): Uint8Array | null

valueOf

  • Returns the primitive value of the specified object.

    Returns Object

writeTo

  • writeTo(writer: Writer): void

Static _fromJsValue

  • _fromJsValue(jsValue: any, annotations: string[]): Value

Static _getIonType