Wrapper class for the Region data structure, which describes a region of WebAssembly's linear memory that has been allocated by the VM.

Note that this class is passed a pointer to the data structure, and the Region's members (offset: u32, capacity: u32, length: u32) are read from that pointer as they are laid out in the data structure.

Hierarchy

  • Region

Constructors

  • Parameters

    • memory: Memory

      The WebAssembly.Memory object that this region is associated

    • ptr: number

      The offset of the region's data structure in memory

    Returns Region

Properties

memory: Memory
ptr: number
region_info: Uint32Array

The region's data structure laid out in memory.

Accessors

  • get b64(): string
  • Get a base64-encoded string of the region's data.

    Returns string

  • get capacity(): number
  • Returns number

  • set capacity(val): void
  • Parameters

    • val: number

    Returns void

  • get data(): Uint8Array
  • Get a byte-slice of the region's data.

    Returns Uint8Array

  • get json(): object
  • Parse the object of the region's data as JSON.

    Returns object

  • get length(): number
  • Returns number

  • set length(val): void
  • Parameters

    • val: number

    Returns void

  • get offset(): number
  • Returns number

  • set offset(val): void
  • Parameters

    • val: number

    Returns void

  • get slice(): Uint8Array
  • Get a byte-slice of the entire writable region.

    Returns Uint8Array

  • get str(): string
  • Get a string view of the region's data.

    Returns string

Methods

  • Reads the region's data as a Uint8Array.

    Returns Uint8Array

    The byte-slice of the region's data.

  • Returns string

  • Parse the region's data as JSON.

    Returns object

    The region's data as a JSON object.

  • Reads the region's data as a String.

    Returns string

    The region's data as a string.

  • Write a byte-slice to the region.

    Parameters

    • bytes: Uint8Array

      The bytes to write to the region

    Returns void

  • Write bytes encoded as base64 to the region.

    Parameters

    • b64: string

      bytes encoded as base64

    Returns void

  • Write a JSON object to the region as a string.

    Parameters

    • obj: object

      The object to write to the region

    Returns void

  • Write a string to the region.

    Parameters

    • str: string

      The string to write to the region

    Returns void

©2020 - 2024 Oraichain Foundation