Options
All
  • Public
  • Public/Protected
  • All
Menu

Represent a contiguous sequence of a specific layout as an Array.

Factory: {@link module:Layout.seq|seq}

param elementLayout

initializer for {@link Sequence#elementLayout|elementLayout}.

param count

initializer for {@link Sequence#count|count}. The parameter must be either a positive integer or an instance of ExternalLayout.

param [property]

initializer for {@link Layout#property|property}.

Type parameters

  • T

Hierarchy

Index

Constructors

constructor

Properties

Optional boundConstructor_

boundConstructor_?: any

count

count: number | ExternalLayout

elementLayout

elementLayout: Layout<T>

Optional property

property?: string

span

span: number

Methods

decode

  • decode(b: Uint8Array, offset?: number): T[]

encode

  • encode(src: T[], b: Uint8Array, offset?: number): number
  • Implement {@link Layout#encode|encode} for Sequence.

    NOTE If src is shorter than {@link Sequence#count|count} then the unused space in the buffer is left unchanged. If src is longer than {@link Sequence#count|count} the unneeded elements are ignored.

    NOTE If {@link Layout#count|count} is an instance of ExternalLayout then the length of src will be encoded as the count after src is encoded.

    Parameters

    • src: T[]
    • b: Uint8Array
    • offset: number = 0

    Returns number

fromArray

  • Create an object from layout properties and an array of values.

    NOTE This function returns undefined if invoked on a layout that does not return its value as an Object. Objects are returned for things that are a Structure, which includes variant layouts if they are structures, and excludes Unions. If you want this feature for a union you must use getVariant to select the desired layout.

    Parameters

    • values: any[]

      an array of values that correspond to the default order for properties. As with {@link Layout#decode|decode} layout elements that have no property name are skipped when iterating over the array values. Only the top-level properties are assigned; arguments are not assigned to properties of contained layouts. Any unused values are ignored.

    Returns undefined | LayoutObject

getSpan

  • getSpan(b: Uint8Array, offset?: number): number

makeDestinationObject

replicate

  • replicate(property: string): Sequence<T>
  • Replicate the layout using a new property.

    This function must be used to get a structurally-equivalent layout with a different name since all Layout instances are immutable.

    NOTE This is a shallow copy. All fields except {@link Layout#property|property} are strictly equal to the origin layout.

    Parameters

    • property: string

      the value for {@link Layout#property|property} in the replica.

    Returns Sequence<T>

    • the copy with {@link Layout#property|property} set to property.

Generated using TypeDoc