Options
All
  • Public
  • Public/Protected
  • All
Menu

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] https://amazon-ion.github.io/ion-docs/docs/spec.html#struct

Hierarchy

  • __type<ObjectConstructor, this> & Object
    • Struct

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.

    • annotations: string[] = []

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

    Returns Struct

Properties

_ionAnnotations

_ionAnnotations: string[]

_ionType

_ionType: IonType

constructor

constructor: Function

The initial value of Object.prototype.constructor is the standard built-in Object constructor.

should

should: Assertion

Methods

[Symbol.iterator]

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

_ionValueEquals

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

_setAnnotations

  • _setAnnotations(annotations: string[]): void
  • Parameters

    • annotations: string[]

    Returns void

_unsupportedOperation

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

    Parameters

    • functionName: string

    Returns never

_valueEquals

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

    • other: any
    • options: { epsilon?: null | number; ignoreAnnotations?: boolean; ignoreTimestampPrecision?: boolean; onlyCompareIon?: boolean } = ...
      • Optional epsilon?: null | number
      • Optional ignoreAnnotations?: boolean
      • Optional ignoreTimestampPrecision?: boolean
      • Optional onlyCompareIon?: boolean

    Returns boolean

allFields

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

as

bigIntValue

  • bigIntValue(): null | bigint
  • Returns null | bigint

booleanValue

  • booleanValue(): null | boolean
  • Returns null | boolean

dateValue

  • dateValue(): null | Date
  • Returns null | Date

decimalValue

  • Returns null | Decimal

deleteField

  • deleteField(name: string): boolean
  • Parameters

    • name: string

    Returns boolean

elements

equals

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

    Parameters

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

    Returns boolean

fieldNames

  • fieldNames(): string[]
  • Returns string[]

fields

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

get

getAll

getAnnotations

  • getAnnotations(): string[]
  • Returns string[]

getType

hasOwnProperty

  • hasOwnProperty(v: string | number | symbol): boolean
  • Determines whether an object has a property with the specified name.

    Parameters

    • v: string | number | symbol

      A property name.

    Returns boolean

ionEquals

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

    Parameters

    • other: Value
    • options: { epsilon?: null | number; ignoreAnnotations?: boolean; ignoreTimestampPrecision?: boolean } = ...
      • Optional epsilon?: null | number
      • Optional ignoreAnnotations?: boolean
      • Optional ignoreTimestampPrecision?: boolean

    Returns boolean

isNull

  • isNull(): boolean
  • Returns 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(): null | number
  • Returns null | number

propertyIsEnumerable

  • propertyIsEnumerable(v: string | number | symbol): boolean
  • Determines whether a specified property is enumerable.

    Parameters

    • v: string | number | symbol

      A property name.

    Returns boolean

stringValue

  • stringValue(): null | string
  • Returns null | string

timestampValue

toJSON

  • toJSON(): any

toLocaleString

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

    Returns string

toString

  • toString(): string
  • Returns string

uInt8ArrayValue

  • uInt8ArrayValue(): null | Uint8Array
  • Returns null | Uint8Array

valueOf

  • valueOf(): Object
  • Returns the primitive value of the specified object.

    Returns Object

writeTo

  • writeTo(writer: Writer): void
  • Parameters

    Returns void

Static _fromJsValue

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

    • jsValue: any
    • annotations: string[]

    Returns Value

Static _getIonType

Static assign

  • assign<T, U>(target: T, source: U): T & U
  • assign<T, U, V>(target: T, source1: U, source2: V): T & U & V
  • assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W
  • assign(target: object, ...sources: any[]): any
  • Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

    Type parameters

    • T

    • U

    Parameters

    • target: T

      The target object to copy to.

    • source: U

      The source object from which to copy properties.

    Returns T & U

  • Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

    Type parameters

    • T

    • U

    • V

    Parameters

    • target: T

      The target object to copy to.

    • source1: U

      The first source object from which to copy properties.

    • source2: V

      The second source object from which to copy properties.

    Returns T & U & V

  • Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

    Type parameters

    • T

    • U

    • V

    • W

    Parameters

    • target: T

      The target object to copy to.

    • source1: U

      The first source object from which to copy properties.

    • source2: V

      The second source object from which to copy properties.

    • source3: W

      The third source object from which to copy properties.

    Returns T & U & V & W

  • Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.

    Parameters

    • target: object

      The target object to copy to.

    • Rest ...sources: any[]

      One or more source objects from which to copy properties

    Returns any

Static create

  • create(o: null | object): any
  • create(o: null | object, properties: PropertyDescriptorMap & ThisType<any>): any
  • Creates an object that has the specified prototype or that has null prototype.

    Parameters

    • o: null | object

      Object to use as a prototype. May be null.

    Returns any

  • Creates an object that has the specified prototype, and that optionally contains specified properties.

    Parameters

    • o: null | object

      Object to use as a prototype. May be null

    • properties: PropertyDescriptorMap & ThisType<any>

      JavaScript object that contains one or more property descriptors.

    Returns any

Static defineProperties

  • defineProperties(o: any, properties: PropertyDescriptorMap & ThisType<any>): any
  • Adds one or more properties to an object, and/or modifies attributes of existing properties.

    Parameters

    • o: any

      Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object.

    • properties: PropertyDescriptorMap & ThisType<any>

      JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property.

    Returns any

Static defineProperty

  • defineProperty(o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>): any
  • Adds a property to an object, or modifies attributes of an existing property.

    Parameters

    • o: any

      Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object.

    • p: string | number | symbol

      The property name.

    • attributes: PropertyDescriptor & ThisType<any>

      Descriptor for the property. It can be for a data property or an accessor property.

    Returns any

Static entries

  • entries<T>(o: {} | ArrayLike<T>): [string, T][]
  • entries(o: {}): [string, any][]
  • Returns an array of key/values of the enumerable properties of an object

    Type parameters

    • T

    Parameters

    • o: {} | ArrayLike<T>

      Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

    Returns [string, T][]

  • Returns an array of key/values of the enumerable properties of an object

    Parameters

    • o: {}

      Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

    Returns [string, any][]

Static freeze

  • freeze<T>(a: T[]): readonly T[]
  • freeze<T>(f: T): T
  • freeze<T>(o: T): Readonly<T>
  • Prevents the modification of existing property attributes and values, and prevents the addition of new properties.

    Type parameters

    • T

    Parameters

    • a: T[]

    Returns readonly T[]

  • Prevents the modification of existing property attributes and values, and prevents the addition of new properties.

    Type parameters

    • T: Function

    Parameters

    • f: T

    Returns T

  • Prevents the modification of existing property attributes and values, and prevents the addition of new properties.

    Type parameters

    • T

    Parameters

    • o: T

      Object on which to lock the attributes.

    Returns Readonly<T>

Static fromEntries

  • fromEntries<T>(entries: Iterable<readonly [string | number | symbol, T]>): {}
  • fromEntries(entries: Iterable<readonly any[]>): any
  • Returns an object created by key-value entries for properties and methods

    Type parameters

    • T = any

    Parameters

    • entries: Iterable<readonly [string | number | symbol, T]>

      An iterable object that contains key-value entries for properties and methods.

    Returns {}

    • [k: string]: T
  • Returns an object created by key-value entries for properties and methods

    Parameters

    • entries: Iterable<readonly any[]>

      An iterable object that contains key-value entries for properties and methods.

    Returns any

Static getOwnPropertyDescriptor

  • getOwnPropertyDescriptor(o: any, p: string | number | symbol): undefined | PropertyDescriptor
  • Gets the own property descriptor of the specified object. An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.

    Parameters

    • o: any

      Object that contains the property.

    • p: string | number | symbol

      Name of the property.

    Returns undefined | PropertyDescriptor

Static getOwnPropertyDescriptors

  • getOwnPropertyDescriptors<T>(o: T): {[ P in string | number | symbol]: TypedPropertyDescriptor<T[P]> } & {}
  • Returns an object containing all own property descriptors of an object

    Type parameters

    • T

    Parameters

    • o: T

      Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

    Returns {[ P in string | number | symbol]: TypedPropertyDescriptor<T[P]> } & {}

Static getOwnPropertyNames

  • getOwnPropertyNames(o: any): string[]
  • Returns the names of the own properties of an object. The own properties of an object are those that are defined directly on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions.

    Parameters

    • o: any

      Object that contains the own properties.

    Returns string[]

Static getOwnPropertySymbols

  • getOwnPropertySymbols(o: any): symbol[]
  • Returns an array of all symbol properties found directly on object o.

    Parameters

    • o: any

      Object to retrieve the symbols from.

    Returns symbol[]

Static getPrototypeOf

  • getPrototypeOf(o: any): any
  • Returns the prototype of an object.

    Parameters

    • o: any

      The object that references the prototype.

    Returns any

Static is

  • is(value1: any, value2: any): boolean
  • Returns true if the values are the same value, false otherwise.

    Parameters

    • value1: any

      The first value.

    • value2: any

      The second value.

    Returns boolean

Static isExtensible

  • isExtensible(o: any): boolean
  • Returns a value that indicates whether new properties can be added to an object.

    Parameters

    • o: any

      Object to test.

    Returns boolean

Static isFrozen

  • isFrozen(o: any): boolean
  • Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object.

    Parameters

    • o: any

      Object to test.

    Returns boolean

Static isSealed

  • isSealed(o: any): boolean
  • Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.

    Parameters

    • o: any

      Object to test.

    Returns boolean

Static keys

  • keys(o: object): string[]
  • keys(o: {}): string[]
  • Returns the names of the enumerable string properties and methods of an object.

    Parameters

    • o: object

      Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

    Returns string[]

  • Returns the names of the enumerable string properties and methods of an object.

    Parameters

    • o: {}

      Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

    Returns string[]

Static preventExtensions

  • preventExtensions<T>(o: T): T
  • Prevents the addition of new properties to an object.

    Type parameters

    • T

    Parameters

    • o: T

      Object to make non-extensible.

    Returns T

Static seal

  • seal<T>(o: T): T
  • Prevents the modification of attributes of existing properties, and prevents the addition of new properties.

    Type parameters

    • T

    Parameters

    • o: T

      Object on which to lock the attributes.

    Returns T

Static setPrototypeOf

  • setPrototypeOf(o: any, proto: null | object): any
  • Sets the prototype of a specified object o to object proto or null. Returns the object o.

    Parameters

    • o: any

      The object to change its prototype.

    • proto: null | object

      The value of the new prototype or null.

    Returns any

Static values

  • values<T>(o: {} | ArrayLike<T>): T[]
  • values(o: {}): any[]
  • Returns an array of values of the enumerable properties of an object

    Type parameters

    • T

    Parameters

    • o: {} | ArrayLike<T>

      Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

    Returns T[]

  • Returns an array of values of the enumerable properties of an object

    Parameters

    • o: {}

      Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.

    Returns any[]