Dynamic module ref-union

Index

Variables

Variables

UnionType: UnionType

This is the constructor of the Struct type that gets returned.

Invoke it with new to create a new Buffer instance backing the union. Pass it an existing Buffer instance to use that as the backing buffer. Pass in an Object containing the union fields to auto-populate the union with the data.

constructor

(arg: Buffer, data?: {}): any

Pass it an existing Buffer instance to use that as the backing buffer.

Parameters

  • arg: Buffer
  • data?: {} optional

Returns

any

(data?: {}): any

Parameters

  • data?: {} optional

Returns

any

constructor(arg: Buffer, data?: {}): any

Pass it an existing Buffer instance to use that as the backing buffer.

Parameters

  • arg: Buffer
  • data?: {} optional

Returns

any

constructor(data?: {}): any

Parameters

  • data?: {} optional

Returns

any

optional public alignment?: number

The alignment of this datatype when placed inside a struct.

public fields: { [key: string]: { type: "ref".Type; }; }

(): { type: "ref".Type; }

Returns

{ type: "ref".Type; }

public indirection: number

The current level of indirection of the buffer.

optional public name?: string

The name to use during debugging for this datatype.

public size: number

The size in bytes required to hold this datatype.

public defineProperty(name: string, type: Type)

Adds a new field to the union instance with the given name and type. Note that this function will throw an Error if any instances of the union type have already been created, therefore this function must be called at the beginning, before any instances are created.

Parameters

  • name: string
  • type: Type

public defineProperty(name: string, type: string)

Adds a new field to the union instance with the given name and type. Note that this function will throw an Error if any instances of the union type have already been created, therefore this function must be called at the beginning, before any instances are created.

Parameters

  • name: string
  • type: string

public get(buffer: Buffer, offset: number): any

To invoke when ref.get is invoked on a buffer of this type.

Parameters

  • buffer: Buffer
  • offset: number

Returns

any

public set(buffer: Buffer, offset: number, value: any)

To invoke when ref.set is invoked on a buffer of this type.

Parameters

  • buffer: Buffer
  • offset: number
  • value: any

public toString(): string

Custom for union type instances.

override

Returns

string