text: // Copyright 2021 the V8 project authors. All rights reserved.
  // Use of this source code is governed by a BSD-style license that can be
  // found in the LICENSE file.
  
  class MyUint8Array extends Uint8Array {};
  class MyBigInt64Array extends BigInt64Array {};
  
  const ctors = [
    Uint8Array,
    Int8Array,
    Uint16Array,
    Int16Array,
    Int32Array,
    Float32Array,
    Float64Array,
    Uint8ClampedArray,
    BigUint64Array,
    BigInt64Array,
    MyUint8Array,
    MyBigInt64Array,
  ];
  
  function ReadDataFromBuffer(ab, ctor) {
    let result = [];
    const ta = new ctor(ab, 0, ab.byteLength / ctor.BYTES_PER_ELEMENT);
    for (let item of ta) {
      result.push(Number(item));
    }
    return result;
  }
  
  function WriteToTypedArray(array, index, value) {
    if (array instanceof BigInt64Array ||
        array instanceof BigUint64Array) {
      array[index] = BigInt(value);
    } else {
      array[index] = value;
    }
  }
  
  function ToNumbers(array) {
    let result = [];
    for (let item of array) {
      result.push(Number(item));
    }
    return result;
  }
  
  function FillHelper(ta, n, start, end) {
    if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) {
      ta.fill(BigInt(n), start, end);
    } else {
      ta.fill(n, start, end);
    }
  }
  