/**
 * Safe typed array pointer for WASM
 */
export class WasmTypedArray {
    _memory;
    _byteOffset;
    _length;
    _array;
    /**
     * Create a safe typed array pointer for WASM
     *
     * @param typedArrayConstructor typed array constructor
     * @param memory WebAssembly memory
     * @param byteOffset byte offset of the typed array
     * @param length length of the typed array
     */
    constructor(typedArrayConstructor, memory, byteOffset, length) {
        this._memory = memory;
        this._byteOffset = byteOffset;
        this._length = length;
        this._array = new typedArrayConstructor(memory.buffer, byteOffset, length);
    }
    /**
     * Get the typed array
     */
    get array() {
        if (this._array.length !== this._length) {
            this._array = new this._array.constructor(this._memory.buffer, this._byteOffset, this._length);
        }
        return this._array;
    }
}
