tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

float16.js (42238B)


      1 /**
      2 * AUTO-GENERATED - DO NOT EDIT. Source: https://github.com/gpuweb/cts
      3 **/ /*! @petamoriken/float16 v3.8.6 | MIT License - https://github.com/petamoriken/float16 */const THIS_IS_NOT_AN_OBJECT = "This is not an object";
      4 const THIS_IS_NOT_A_FLOAT16ARRAY_OBJECT = "This is not a Float16Array object";
      5 const THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY =
      6 "This constructor is not a subclass of Float16Array";
      7 const THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT =
      8 "The constructor property value is not an object";
      9 const SPECIES_CONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY_OBJECT =
     10 "Species constructor didn't return TypedArray object";
     11 const DERIVED_CONSTRUCTOR_CREATED_TYPEDARRAY_OBJECT_WHICH_WAS_TOO_SMALL_LENGTH =
     12 "Derived constructor created TypedArray object which was too small length";
     13 const ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER =
     14 "Attempting to access detached ArrayBuffer";
     15 const CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT =
     16 "Cannot convert undefined or null to object";
     17 const CANNOT_MIX_BIGINT_AND_OTHER_TYPES =
     18 "Cannot mix BigInt and other types, use explicit conversions";
     19 const ITERATOR_PROPERTY_IS_NOT_CALLABLE = "@@iterator property is not callable";
     20 const REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE =
     21 "Reduce of empty array with no initial value";
     22 const THE_COMPARISON_FUNCTION_MUST_BE_EITHER_A_FUNCTION_OR_UNDEFINED =
     23 "The comparison function must be either a function or undefined";
     24 const OFFSET_IS_OUT_OF_BOUNDS = "Offset is out of bounds";
     25 
     26 function uncurryThis(target) {
     27  return (thisArg, ...args) => {
     28    return ReflectApply(target, thisArg, args);
     29  };
     30 }
     31 function uncurryThisGetter(target, key) {
     32  return uncurryThis(
     33    ReflectGetOwnPropertyDescriptor(
     34      target,
     35      key
     36    ).get
     37  );
     38 }
     39 const {
     40  apply: ReflectApply,
     41  construct: ReflectConstruct,
     42  defineProperty: ReflectDefineProperty,
     43  get: ReflectGet,
     44  getOwnPropertyDescriptor: ReflectGetOwnPropertyDescriptor,
     45  getPrototypeOf: ReflectGetPrototypeOf,
     46  has: ReflectHas,
     47  ownKeys: ReflectOwnKeys,
     48  set: ReflectSet,
     49  setPrototypeOf: ReflectSetPrototypeOf
     50 } = Reflect;
     51 const NativeProxy = Proxy;
     52 const {
     53  EPSILON,
     54  MAX_SAFE_INTEGER,
     55  isFinite: NumberIsFinite,
     56  isNaN: NumberIsNaN
     57 } = Number;
     58 const {
     59  iterator: SymbolIterator,
     60  species: SymbolSpecies,
     61  toStringTag: SymbolToStringTag,
     62  for: SymbolFor
     63 } = Symbol;
     64 const NativeObject = Object;
     65 const {
     66  create: ObjectCreate,
     67  defineProperty: ObjectDefineProperty,
     68  freeze: ObjectFreeze,
     69  is: ObjectIs
     70 } = NativeObject;
     71 const ObjectPrototype = NativeObject.prototype;
     72 const ObjectPrototype__lookupGetter__ = ObjectPrototype.__lookupGetter__ ?
     73 uncurryThis(ObjectPrototype.__lookupGetter__) :
     74 (object, key) => {
     75  if (object == null) {
     76    throw NativeTypeError(
     77      CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT
     78    );
     79  }
     80  let target = NativeObject(object);
     81  do {
     82    const descriptor = ReflectGetOwnPropertyDescriptor(target, key);
     83    if (descriptor !== undefined) {
     84      if (ObjectHasOwn(descriptor, "get")) {
     85        return descriptor.get;
     86      }
     87      return;
     88    }
     89  } while ((target = ReflectGetPrototypeOf(target)) !== null);
     90 };
     91 const ObjectHasOwn = NativeObject.hasOwn ||
     92 uncurryThis(ObjectPrototype.hasOwnProperty);
     93 const NativeArray = Array;
     94 const ArrayIsArray = NativeArray.isArray;
     95 const ArrayPrototype = NativeArray.prototype;
     96 const ArrayPrototypeJoin = uncurryThis(ArrayPrototype.join);
     97 const ArrayPrototypePush = uncurryThis(ArrayPrototype.push);
     98 const ArrayPrototypeToLocaleString = uncurryThis(
     99  ArrayPrototype.toLocaleString
    100 );
    101 const NativeArrayPrototypeSymbolIterator = ArrayPrototype[SymbolIterator];
    102 const ArrayPrototypeSymbolIterator = uncurryThis(NativeArrayPrototypeSymbolIterator);
    103 const {
    104  abs: MathAbs,
    105  trunc: MathTrunc
    106 } = Math;
    107 const NativeArrayBuffer = ArrayBuffer;
    108 const ArrayBufferIsView = NativeArrayBuffer.isView;
    109 const ArrayBufferPrototype = NativeArrayBuffer.prototype;
    110 const ArrayBufferPrototypeSlice = uncurryThis(ArrayBufferPrototype.slice);
    111 const ArrayBufferPrototypeGetByteLength = uncurryThisGetter(ArrayBufferPrototype, "byteLength");
    112 const NativeSharedArrayBuffer = typeof SharedArrayBuffer !== "undefined" ? SharedArrayBuffer : null;
    113 const SharedArrayBufferPrototypeGetByteLength = NativeSharedArrayBuffer &&
    114 uncurryThisGetter(NativeSharedArrayBuffer.prototype, "byteLength");
    115 const TypedArray = ReflectGetPrototypeOf(Uint8Array);
    116 const TypedArrayFrom = TypedArray.from;
    117 const TypedArrayPrototype = TypedArray.prototype;
    118 const NativeTypedArrayPrototypeSymbolIterator = TypedArrayPrototype[SymbolIterator];
    119 const TypedArrayPrototypeKeys = uncurryThis(TypedArrayPrototype.keys);
    120 const TypedArrayPrototypeValues = uncurryThis(
    121  TypedArrayPrototype.values
    122 );
    123 const TypedArrayPrototypeEntries = uncurryThis(
    124  TypedArrayPrototype.entries
    125 );
    126 const TypedArrayPrototypeSet = uncurryThis(TypedArrayPrototype.set);
    127 const TypedArrayPrototypeReverse = uncurryThis(
    128  TypedArrayPrototype.reverse
    129 );
    130 const TypedArrayPrototypeFill = uncurryThis(TypedArrayPrototype.fill);
    131 const TypedArrayPrototypeCopyWithin = uncurryThis(
    132  TypedArrayPrototype.copyWithin
    133 );
    134 const TypedArrayPrototypeSort = uncurryThis(TypedArrayPrototype.sort);
    135 const TypedArrayPrototypeSlice = uncurryThis(TypedArrayPrototype.slice);
    136 const TypedArrayPrototypeSubarray = uncurryThis(
    137  TypedArrayPrototype.subarray
    138 );
    139 const TypedArrayPrototypeGetBuffer = uncurryThisGetter(
    140  TypedArrayPrototype,
    141  "buffer"
    142 );
    143 const TypedArrayPrototypeGetByteOffset = uncurryThisGetter(
    144  TypedArrayPrototype,
    145  "byteOffset"
    146 );
    147 const TypedArrayPrototypeGetLength = uncurryThisGetter(
    148  TypedArrayPrototype,
    149  "length"
    150 );
    151 const TypedArrayPrototypeGetSymbolToStringTag = uncurryThisGetter(
    152  TypedArrayPrototype,
    153  SymbolToStringTag
    154 );
    155 const NativeUint8Array = Uint8Array;
    156 const NativeUint16Array = Uint16Array;
    157 const Uint16ArrayFrom = (...args) => {
    158  return ReflectApply(TypedArrayFrom, NativeUint16Array, args);
    159 };
    160 const NativeUint32Array = Uint32Array;
    161 const NativeFloat32Array = Float32Array;
    162 const ArrayIteratorPrototype = ReflectGetPrototypeOf([][SymbolIterator]());
    163 const ArrayIteratorPrototypeNext = uncurryThis(ArrayIteratorPrototype.next);
    164 const GeneratorPrototypeNext = uncurryThis(function* () {}().next);
    165 const IteratorPrototype = ReflectGetPrototypeOf(ArrayIteratorPrototype);
    166 const DataViewPrototype = DataView.prototype;
    167 const DataViewPrototypeGetUint16 = uncurryThis(
    168  DataViewPrototype.getUint16
    169 );
    170 const DataViewPrototypeSetUint16 = uncurryThis(
    171  DataViewPrototype.setUint16
    172 );
    173 const NativeTypeError = TypeError;
    174 const NativeRangeError = RangeError;
    175 const NativeWeakSet = WeakSet;
    176 const WeakSetPrototype = NativeWeakSet.prototype;
    177 const WeakSetPrototypeAdd = uncurryThis(WeakSetPrototype.add);
    178 const WeakSetPrototypeHas = uncurryThis(WeakSetPrototype.has);
    179 const NativeWeakMap = WeakMap;
    180 const WeakMapPrototype = NativeWeakMap.prototype;
    181 const WeakMapPrototypeGet = uncurryThis(WeakMapPrototype.get);
    182 const WeakMapPrototypeHas = uncurryThis(WeakMapPrototype.has);
    183 const WeakMapPrototypeSet = uncurryThis(WeakMapPrototype.set);
    184 
    185 const arrayIterators = new NativeWeakMap();
    186 const SafeIteratorPrototype = ObjectCreate(null, {
    187  next: {
    188    value: function next() {
    189      const arrayIterator = WeakMapPrototypeGet(arrayIterators, this);
    190      return ArrayIteratorPrototypeNext(arrayIterator);
    191    }
    192  },
    193  [SymbolIterator]: {
    194    value: function values() {
    195      return this;
    196    }
    197  }
    198 });
    199 function safeIfNeeded(array) {
    200  if (
    201  array[SymbolIterator] === NativeArrayPrototypeSymbolIterator &&
    202  ArrayIteratorPrototype.next === ArrayIteratorPrototypeNext)
    203  {
    204    return array;
    205  }
    206  const safe = ObjectCreate(SafeIteratorPrototype);
    207  WeakMapPrototypeSet(arrayIterators, safe, ArrayPrototypeSymbolIterator(array));
    208  return safe;
    209 }
    210 const generators = new NativeWeakMap();
    211 const DummyArrayIteratorPrototype = ObjectCreate(IteratorPrototype, {
    212  next: {
    213    value: function next() {
    214      const generator = WeakMapPrototypeGet(generators, this);
    215      return GeneratorPrototypeNext(generator);
    216    },
    217    writable: true,
    218    configurable: true
    219  }
    220 });
    221 for (const key of ReflectOwnKeys(ArrayIteratorPrototype)) {
    222  if (key === "next") {
    223    continue;
    224  }
    225  ObjectDefineProperty(DummyArrayIteratorPrototype, key, ReflectGetOwnPropertyDescriptor(ArrayIteratorPrototype, key));
    226 }
    227 function wrap(generator) {
    228  const dummy = ObjectCreate(DummyArrayIteratorPrototype);
    229  WeakMapPrototypeSet(generators, dummy, generator);
    230  return dummy;
    231 }
    232 
    233 function isObject(value) {
    234  return (
    235    value !== null && typeof value === "object" ||
    236    typeof value === "function");
    237 
    238 }
    239 function isObjectLike(value) {
    240  return value !== null && typeof value === "object";
    241 }
    242 function isNativeTypedArray(value) {
    243  return TypedArrayPrototypeGetSymbolToStringTag(value) !== undefined;
    244 }
    245 function isNativeBigIntTypedArray(value) {
    246  const typedArrayName = TypedArrayPrototypeGetSymbolToStringTag(value);
    247  return (
    248    typedArrayName === "BigInt64Array" ||
    249    typedArrayName === "BigUint64Array");
    250 
    251 }
    252 function isArrayBuffer(value) {
    253  try {
    254    if (ArrayIsArray(value)) {
    255      return false;
    256    }
    257    ArrayBufferPrototypeGetByteLength(value);
    258    return true;
    259  } catch (e) {
    260    return false;
    261  }
    262 }
    263 function isSharedArrayBuffer(value) {
    264  if (NativeSharedArrayBuffer === null) {
    265    return false;
    266  }
    267  try {
    268    SharedArrayBufferPrototypeGetByteLength(value);
    269    return true;
    270  } catch (e) {
    271    return false;
    272  }
    273 }
    274 function isAnyArrayBuffer(value) {
    275  return isArrayBuffer(value) || isSharedArrayBuffer(value);
    276 }
    277 function isOrdinaryArray(value) {
    278  if (!ArrayIsArray(value)) {
    279    return false;
    280  }
    281  return (
    282    value[SymbolIterator] === NativeArrayPrototypeSymbolIterator &&
    283    ArrayIteratorPrototype.next === ArrayIteratorPrototypeNext);
    284 
    285 }
    286 function isOrdinaryNativeTypedArray(value) {
    287  if (!isNativeTypedArray(value)) {
    288    return false;
    289  }
    290  return (
    291    value[SymbolIterator] === NativeTypedArrayPrototypeSymbolIterator &&
    292    ArrayIteratorPrototype.next === ArrayIteratorPrototypeNext);
    293 
    294 }
    295 function isCanonicalIntegerIndexString(value) {
    296  if (typeof value !== "string") {
    297    return false;
    298  }
    299  const number = +value;
    300  if (value !== number + "") {
    301    return false;
    302  }
    303  if (!NumberIsFinite(number)) {
    304    return false;
    305  }
    306  return number === MathTrunc(number);
    307 }
    308 
    309 const brand = SymbolFor("__Float16Array__");
    310 function hasFloat16ArrayBrand(target) {
    311  if (!isObjectLike(target)) {
    312    return false;
    313  }
    314  const prototype = ReflectGetPrototypeOf(target);
    315  if (!isObjectLike(prototype)) {
    316    return false;
    317  }
    318  const constructor = prototype.constructor;
    319  if (constructor === undefined) {
    320    return false;
    321  }
    322  if (!isObject(constructor)) {
    323    throw NativeTypeError(THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT);
    324  }
    325  return ReflectHas(constructor, brand);
    326 }
    327 
    328 const INVERSE_OF_EPSILON = 1 / EPSILON;
    329 function roundTiesToEven(num) {
    330  return num + INVERSE_OF_EPSILON - INVERSE_OF_EPSILON;
    331 }
    332 const FLOAT16_MIN_VALUE = 6.103515625e-05;
    333 const FLOAT16_MAX_VALUE = 65504;
    334 const FLOAT16_EPSILON = 0.0009765625;
    335 const FLOAT16_EPSILON_MULTIPLIED_BY_FLOAT16_MIN_VALUE = FLOAT16_EPSILON * FLOAT16_MIN_VALUE;
    336 const FLOAT16_EPSILON_DEVIDED_BY_EPSILON = FLOAT16_EPSILON * INVERSE_OF_EPSILON;
    337 function roundToFloat16(num) {
    338  const number = +num;
    339  if (!NumberIsFinite(number) || number === 0) {
    340    return number;
    341  }
    342  const sign = number > 0 ? 1 : -1;
    343  const absolute = MathAbs(number);
    344  if (absolute < FLOAT16_MIN_VALUE) {
    345    return sign * roundTiesToEven(absolute / FLOAT16_EPSILON_MULTIPLIED_BY_FLOAT16_MIN_VALUE) * FLOAT16_EPSILON_MULTIPLIED_BY_FLOAT16_MIN_VALUE;
    346  }
    347  const temp = (1 + FLOAT16_EPSILON_DEVIDED_BY_EPSILON) * absolute;
    348  const result = temp - (temp - absolute);
    349  if (result > FLOAT16_MAX_VALUE || NumberIsNaN(result)) {
    350    return sign * Infinity;
    351  }
    352  return sign * result;
    353 }
    354 const buffer = new NativeArrayBuffer(4);
    355 const floatView = new NativeFloat32Array(buffer);
    356 const uint32View = new NativeUint32Array(buffer);
    357 const baseTable = new NativeUint16Array(512);
    358 const shiftTable = new NativeUint8Array(512);
    359 for (let i = 0; i < 256; ++i) {
    360  const e = i - 127;
    361  if (e < -27) {
    362    baseTable[i] = 0x0000;
    363    baseTable[i | 0x100] = 0x8000;
    364    shiftTable[i] = 24;
    365    shiftTable[i | 0x100] = 24;
    366  } else if (e < -14) {
    367    baseTable[i] = 0x0400 >> -e - 14;
    368    baseTable[i | 0x100] = 0x0400 >> -e - 14 | 0x8000;
    369    shiftTable[i] = -e - 1;
    370    shiftTable[i | 0x100] = -e - 1;
    371  } else if (e <= 15) {
    372    baseTable[i] = e + 15 << 10;
    373    baseTable[i | 0x100] = e + 15 << 10 | 0x8000;
    374    shiftTable[i] = 13;
    375    shiftTable[i | 0x100] = 13;
    376  } else if (e < 128) {
    377    baseTable[i] = 0x7c00;
    378    baseTable[i | 0x100] = 0xfc00;
    379    shiftTable[i] = 24;
    380    shiftTable[i | 0x100] = 24;
    381  } else {
    382    baseTable[i] = 0x7c00;
    383    baseTable[i | 0x100] = 0xfc00;
    384    shiftTable[i] = 13;
    385    shiftTable[i | 0x100] = 13;
    386  }
    387 }
    388 function roundToFloat16Bits(num) {
    389  floatView[0] = roundToFloat16(num);
    390  const f = uint32View[0];
    391  const e = f >> 23 & 0x1ff;
    392  return baseTable[e] + ((f & 0x007fffff) >> shiftTable[e]);
    393 }
    394 const mantissaTable = new NativeUint32Array(2048);
    395 for (let i = 1; i < 1024; ++i) {
    396  let m = i << 13;
    397  let e = 0;
    398  while ((m & 0x00800000) === 0) {
    399    m <<= 1;
    400    e -= 0x00800000;
    401  }
    402  m &= ~0x00800000;
    403  e += 0x38800000;
    404  mantissaTable[i] = m | e;
    405 }
    406 for (let i = 1024; i < 2048; ++i) {
    407  mantissaTable[i] = 0x38000000 + (i - 1024 << 13);
    408 }
    409 const exponentTable = new NativeUint32Array(64);
    410 for (let i = 1; i < 31; ++i) {
    411  exponentTable[i] = i << 23;
    412 }
    413 exponentTable[31] = 0x47800000;
    414 exponentTable[32] = 0x80000000;
    415 for (let i = 33; i < 63; ++i) {
    416  exponentTable[i] = 0x80000000 + (i - 32 << 23);
    417 }
    418 exponentTable[63] = 0xc7800000;
    419 const offsetTable = new NativeUint16Array(64);
    420 for (let i = 1; i < 64; ++i) {
    421  if (i !== 32) {
    422    offsetTable[i] = 1024;
    423  }
    424 }
    425 function convertToNumber(float16bits) {
    426  const i = float16bits >> 10;
    427  uint32View[0] = mantissaTable[offsetTable[i] + (float16bits & 0x3ff)] + exponentTable[i];
    428  return floatView[0];
    429 }
    430 
    431 function ToIntegerOrInfinity(target) {
    432  const number = +target;
    433  if (NumberIsNaN(number) || number === 0) {
    434    return 0;
    435  }
    436  return MathTrunc(number);
    437 }
    438 function ToLength(target) {
    439  const length = ToIntegerOrInfinity(target);
    440  if (length < 0) {
    441    return 0;
    442  }
    443  return length < MAX_SAFE_INTEGER ?
    444  length :
    445  MAX_SAFE_INTEGER;
    446 }
    447 function SpeciesConstructor(target, defaultConstructor) {
    448  if (!isObject(target)) {
    449    throw NativeTypeError(THIS_IS_NOT_AN_OBJECT);
    450  }
    451  const constructor = target.constructor;
    452  if (constructor === undefined) {
    453    return defaultConstructor;
    454  }
    455  if (!isObject(constructor)) {
    456    throw NativeTypeError(THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT);
    457  }
    458  const species = constructor[SymbolSpecies];
    459  if (species == null) {
    460    return defaultConstructor;
    461  }
    462  return species;
    463 }
    464 function IsDetachedBuffer(buffer) {
    465  if (isSharedArrayBuffer(buffer)) {
    466    return false;
    467  }
    468  try {
    469    ArrayBufferPrototypeSlice(buffer, 0, 0);
    470    return false;
    471  } catch (e) {}
    472  return true;
    473 }
    474 function defaultCompare(x, y) {
    475  const isXNaN = NumberIsNaN(x);
    476  const isYNaN = NumberIsNaN(y);
    477  if (isXNaN && isYNaN) {
    478    return 0;
    479  }
    480  if (isXNaN) {
    481    return 1;
    482  }
    483  if (isYNaN) {
    484    return -1;
    485  }
    486  if (x < y) {
    487    return -1;
    488  }
    489  if (x > y) {
    490    return 1;
    491  }
    492  if (x === 0 && y === 0) {
    493    const isXPlusZero = ObjectIs(x, 0);
    494    const isYPlusZero = ObjectIs(y, 0);
    495    if (!isXPlusZero && isYPlusZero) {
    496      return -1;
    497    }
    498    if (isXPlusZero && !isYPlusZero) {
    499      return 1;
    500    }
    501  }
    502  return 0;
    503 }
    504 
    505 const BYTES_PER_ELEMENT = 2;
    506 const float16bitsArrays = new NativeWeakMap();
    507 function isFloat16Array(target) {
    508  return WeakMapPrototypeHas(float16bitsArrays, target) ||
    509  !ArrayBufferIsView(target) && hasFloat16ArrayBrand(target);
    510 }
    511 function assertFloat16Array(target) {
    512  if (!isFloat16Array(target)) {
    513    throw NativeTypeError(THIS_IS_NOT_A_FLOAT16ARRAY_OBJECT);
    514  }
    515 }
    516 function assertSpeciesTypedArray(target, count) {
    517  const isTargetFloat16Array = isFloat16Array(target);
    518  const isTargetTypedArray = isNativeTypedArray(target);
    519  if (!isTargetFloat16Array && !isTargetTypedArray) {
    520    throw NativeTypeError(SPECIES_CONSTRUCTOR_DIDNT_RETURN_TYPEDARRAY_OBJECT);
    521  }
    522  if (typeof count === "number") {
    523    let length;
    524    if (isTargetFloat16Array) {
    525      const float16bitsArray = getFloat16BitsArray(target);
    526      length = TypedArrayPrototypeGetLength(float16bitsArray);
    527    } else {
    528      length = TypedArrayPrototypeGetLength(target);
    529    }
    530    if (length < count) {
    531      throw NativeTypeError(
    532        DERIVED_CONSTRUCTOR_CREATED_TYPEDARRAY_OBJECT_WHICH_WAS_TOO_SMALL_LENGTH
    533      );
    534    }
    535  }
    536  if (isNativeBigIntTypedArray(target)) {
    537    throw NativeTypeError(CANNOT_MIX_BIGINT_AND_OTHER_TYPES);
    538  }
    539 }
    540 function getFloat16BitsArray(float16) {
    541  const float16bitsArray = WeakMapPrototypeGet(float16bitsArrays, float16);
    542  if (float16bitsArray !== undefined) {
    543    const buffer = TypedArrayPrototypeGetBuffer(float16bitsArray);
    544    if (IsDetachedBuffer(buffer)) {
    545      throw NativeTypeError(ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);
    546    }
    547    return float16bitsArray;
    548  }
    549  const buffer = float16.buffer;
    550  if (IsDetachedBuffer(buffer)) {
    551    throw NativeTypeError(ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);
    552  }
    553  const cloned = ReflectConstruct(Float16Array, [
    554  buffer,
    555  float16.byteOffset,
    556  float16.length],
    557  float16.constructor);
    558  return WeakMapPrototypeGet(float16bitsArrays, cloned);
    559 }
    560 function copyToArray(float16bitsArray) {
    561  const length = TypedArrayPrototypeGetLength(float16bitsArray);
    562  const array = [];
    563  for (let i = 0; i < length; ++i) {
    564    array[i] = convertToNumber(float16bitsArray[i]);
    565  }
    566  return array;
    567 }
    568 const TypedArrayPrototypeGetters = new NativeWeakSet();
    569 for (const key of ReflectOwnKeys(TypedArrayPrototype)) {
    570  if (key === SymbolToStringTag) {
    571    continue;
    572  }
    573  const descriptor = ReflectGetOwnPropertyDescriptor(TypedArrayPrototype, key);
    574  if (ObjectHasOwn(descriptor, "get") && typeof descriptor.get === "function") {
    575    WeakSetPrototypeAdd(TypedArrayPrototypeGetters, descriptor.get);
    576  }
    577 }
    578 const handler = ObjectFreeze({
    579  get(target, key, receiver) {
    580    if (isCanonicalIntegerIndexString(key) && ObjectHasOwn(target, key)) {
    581      return convertToNumber(ReflectGet(target, key));
    582    }
    583    if (WeakSetPrototypeHas(TypedArrayPrototypeGetters, ObjectPrototype__lookupGetter__(target, key))) {
    584      return ReflectGet(target, key);
    585    }
    586    return ReflectGet(target, key, receiver);
    587  },
    588  set(target, key, value, receiver) {
    589    if (isCanonicalIntegerIndexString(key) && ObjectHasOwn(target, key)) {
    590      return ReflectSet(target, key, roundToFloat16Bits(value));
    591    }
    592    return ReflectSet(target, key, value, receiver);
    593  },
    594  getOwnPropertyDescriptor(target, key) {
    595    if (isCanonicalIntegerIndexString(key) && ObjectHasOwn(target, key)) {
    596      const descriptor = ReflectGetOwnPropertyDescriptor(target, key);
    597      descriptor.value = convertToNumber(descriptor.value);
    598      return descriptor;
    599    }
    600    return ReflectGetOwnPropertyDescriptor(target, key);
    601  },
    602  defineProperty(target, key, descriptor) {
    603    if (
    604    isCanonicalIntegerIndexString(key) &&
    605    ObjectHasOwn(target, key) &&
    606    ObjectHasOwn(descriptor, "value"))
    607    {
    608      descriptor.value = roundToFloat16Bits(descriptor.value);
    609      return ReflectDefineProperty(target, key, descriptor);
    610    }
    611    return ReflectDefineProperty(target, key, descriptor);
    612  }
    613 });
    614 class Float16Array {
    615  constructor(input, _byteOffset, _length) {
    616    let float16bitsArray;
    617    if (isFloat16Array(input)) {
    618      float16bitsArray = ReflectConstruct(NativeUint16Array, [getFloat16BitsArray(input)], new.target);
    619    } else if (isObject(input) && !isAnyArrayBuffer(input)) {
    620      let list;
    621      let length;
    622      if (isNativeTypedArray(input)) {
    623        list = input;
    624        length = TypedArrayPrototypeGetLength(input);
    625        const buffer = TypedArrayPrototypeGetBuffer(input);
    626        if (IsDetachedBuffer(buffer)) {
    627          throw NativeTypeError(ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);
    628        }
    629        if (isNativeBigIntTypedArray(input)) {
    630          throw NativeTypeError(CANNOT_MIX_BIGINT_AND_OTHER_TYPES);
    631        }
    632        const data = new NativeArrayBuffer(
    633          length * BYTES_PER_ELEMENT
    634        );
    635        float16bitsArray = ReflectConstruct(NativeUint16Array, [data], new.target);
    636      } else {
    637        const iterator = input[SymbolIterator];
    638        if (iterator != null && typeof iterator !== "function") {
    639          throw NativeTypeError(ITERATOR_PROPERTY_IS_NOT_CALLABLE);
    640        }
    641        if (iterator != null) {
    642          if (isOrdinaryArray(input)) {
    643            list = input;
    644            length = input.length;
    645          } else {
    646            list = [...input];
    647            length = list.length;
    648          }
    649        } else {
    650          list = input;
    651          length = ToLength(list.length);
    652        }
    653        float16bitsArray = ReflectConstruct(NativeUint16Array, [length], new.target);
    654      }
    655      for (let i = 0; i < length; ++i) {
    656        float16bitsArray[i] = roundToFloat16Bits(list[i]);
    657      }
    658    } else {
    659      float16bitsArray = ReflectConstruct(NativeUint16Array, arguments, new.target);
    660    }
    661    const proxy = new NativeProxy(float16bitsArray, handler);
    662    WeakMapPrototypeSet(float16bitsArrays, proxy, float16bitsArray);
    663    return proxy;
    664  }
    665  static from(src, ...opts) {
    666    const Constructor = this;
    667    if (!ReflectHas(Constructor, brand)) {
    668      throw NativeTypeError(
    669        THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY
    670      );
    671    }
    672    if (Constructor === Float16Array) {
    673      if (isFloat16Array(src) && opts.length === 0) {
    674        const float16bitsArray = getFloat16BitsArray(src);
    675        const uint16 = new NativeUint16Array(
    676          TypedArrayPrototypeGetBuffer(float16bitsArray),
    677          TypedArrayPrototypeGetByteOffset(float16bitsArray),
    678          TypedArrayPrototypeGetLength(float16bitsArray)
    679        );
    680        return new Float16Array(
    681          TypedArrayPrototypeGetBuffer(TypedArrayPrototypeSlice(uint16))
    682        );
    683      }
    684      if (opts.length === 0) {
    685        return new Float16Array(
    686          TypedArrayPrototypeGetBuffer(
    687            Uint16ArrayFrom(src, roundToFloat16Bits)
    688          )
    689        );
    690      }
    691      const mapFunc = opts[0];
    692      const thisArg = opts[1];
    693      return new Float16Array(
    694        TypedArrayPrototypeGetBuffer(
    695          Uint16ArrayFrom(src, function (val, ...args) {
    696            return roundToFloat16Bits(
    697              ReflectApply(mapFunc, this, [val, ...safeIfNeeded(args)])
    698            );
    699          }, thisArg)
    700        )
    701      );
    702    }
    703    let list;
    704    let length;
    705    const iterator = src[SymbolIterator];
    706    if (iterator != null && typeof iterator !== "function") {
    707      throw NativeTypeError(ITERATOR_PROPERTY_IS_NOT_CALLABLE);
    708    }
    709    if (iterator != null) {
    710      if (isOrdinaryArray(src)) {
    711        list = src;
    712        length = src.length;
    713      } else if (isOrdinaryNativeTypedArray(src)) {
    714        list = src;
    715        length = TypedArrayPrototypeGetLength(src);
    716      } else {
    717        list = [...src];
    718        length = list.length;
    719      }
    720    } else {
    721      if (src == null) {
    722        throw NativeTypeError(
    723          CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT
    724        );
    725      }
    726      list = NativeObject(src);
    727      length = ToLength(list.length);
    728    }
    729    const array = new Constructor(length);
    730    if (opts.length === 0) {
    731      for (let i = 0; i < length; ++i) {
    732        array[i] = list[i];
    733      }
    734    } else {
    735      const mapFunc = opts[0];
    736      const thisArg = opts[1];
    737      for (let i = 0; i < length; ++i) {
    738        array[i] = ReflectApply(mapFunc, thisArg, [list[i], i]);
    739      }
    740    }
    741    return array;
    742  }
    743  static of(...items) {
    744    const Constructor = this;
    745    if (!ReflectHas(Constructor, brand)) {
    746      throw NativeTypeError(
    747        THIS_CONSTRUCTOR_IS_NOT_A_SUBCLASS_OF_FLOAT16ARRAY
    748      );
    749    }
    750    const length = items.length;
    751    if (Constructor === Float16Array) {
    752      const proxy = new Float16Array(length);
    753      const float16bitsArray = getFloat16BitsArray(proxy);
    754      for (let i = 0; i < length; ++i) {
    755        float16bitsArray[i] = roundToFloat16Bits(items[i]);
    756      }
    757      return proxy;
    758    }
    759    const array = new Constructor(length);
    760    for (let i = 0; i < length; ++i) {
    761      array[i] = items[i];
    762    }
    763    return array;
    764  }
    765  keys() {
    766    assertFloat16Array(this);
    767    const float16bitsArray = getFloat16BitsArray(this);
    768    return TypedArrayPrototypeKeys(float16bitsArray);
    769  }
    770  values() {
    771    assertFloat16Array(this);
    772    const float16bitsArray = getFloat16BitsArray(this);
    773    return wrap(function* () {
    774      for (const val of TypedArrayPrototypeValues(float16bitsArray)) {
    775        yield convertToNumber(val);
    776      }
    777    }());
    778  }
    779  entries() {
    780    assertFloat16Array(this);
    781    const float16bitsArray = getFloat16BitsArray(this);
    782    return wrap(function* () {
    783      for (const [i, val] of TypedArrayPrototypeEntries(float16bitsArray)) {
    784        yield [i, convertToNumber(val)];
    785      }
    786    }());
    787  }
    788  at(index) {
    789    assertFloat16Array(this);
    790    const float16bitsArray = getFloat16BitsArray(this);
    791    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    792    const relativeIndex = ToIntegerOrInfinity(index);
    793    const k = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;
    794    if (k < 0 || k >= length) {
    795      return;
    796    }
    797    return convertToNumber(float16bitsArray[k]);
    798  }
    799  with(index, value) {
    800    assertFloat16Array(this);
    801    const float16bitsArray = getFloat16BitsArray(this);
    802    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    803    const relativeIndex = ToIntegerOrInfinity(index);
    804    const k = relativeIndex >= 0 ? relativeIndex : length + relativeIndex;
    805    const number = +value;
    806    if (k < 0 || k >= length) {
    807      throw NativeRangeError(OFFSET_IS_OUT_OF_BOUNDS);
    808    }
    809    const uint16 = new NativeUint16Array(
    810      TypedArrayPrototypeGetBuffer(float16bitsArray),
    811      TypedArrayPrototypeGetByteOffset(float16bitsArray),
    812      TypedArrayPrototypeGetLength(float16bitsArray)
    813    );
    814    const cloned = new Float16Array(
    815      TypedArrayPrototypeGetBuffer(
    816        TypedArrayPrototypeSlice(uint16)
    817      )
    818    );
    819    const array = getFloat16BitsArray(cloned);
    820    array[k] = roundToFloat16Bits(number);
    821    return cloned;
    822  }
    823  map(callback, ...opts) {
    824    assertFloat16Array(this);
    825    const float16bitsArray = getFloat16BitsArray(this);
    826    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    827    const thisArg = opts[0];
    828    const Constructor = SpeciesConstructor(float16bitsArray, Float16Array);
    829    if (Constructor === Float16Array) {
    830      const proxy = new Float16Array(length);
    831      const array = getFloat16BitsArray(proxy);
    832      for (let i = 0; i < length; ++i) {
    833        const val = convertToNumber(float16bitsArray[i]);
    834        array[i] = roundToFloat16Bits(
    835          ReflectApply(callback, thisArg, [val, i, this])
    836        );
    837      }
    838      return proxy;
    839    }
    840    const array = new Constructor(length);
    841    assertSpeciesTypedArray(array, length);
    842    for (let i = 0; i < length; ++i) {
    843      const val = convertToNumber(float16bitsArray[i]);
    844      array[i] = ReflectApply(callback, thisArg, [val, i, this]);
    845    }
    846    return array;
    847  }
    848  filter(callback, ...opts) {
    849    assertFloat16Array(this);
    850    const float16bitsArray = getFloat16BitsArray(this);
    851    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    852    const thisArg = opts[0];
    853    const kept = [];
    854    for (let i = 0; i < length; ++i) {
    855      const val = convertToNumber(float16bitsArray[i]);
    856      if (ReflectApply(callback, thisArg, [val, i, this])) {
    857        ArrayPrototypePush(kept, val);
    858      }
    859    }
    860    const Constructor = SpeciesConstructor(float16bitsArray, Float16Array);
    861    const array = new Constructor(kept);
    862    assertSpeciesTypedArray(array);
    863    return array;
    864  }
    865  reduce(callback, ...opts) {
    866    assertFloat16Array(this);
    867    const float16bitsArray = getFloat16BitsArray(this);
    868    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    869    if (length === 0 && opts.length === 0) {
    870      throw NativeTypeError(REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE);
    871    }
    872    let accumulator, start;
    873    if (opts.length === 0) {
    874      accumulator = convertToNumber(float16bitsArray[0]);
    875      start = 1;
    876    } else {
    877      accumulator = opts[0];
    878      start = 0;
    879    }
    880    for (let i = start; i < length; ++i) {
    881      accumulator = callback(
    882        accumulator,
    883        convertToNumber(float16bitsArray[i]),
    884        i,
    885        this
    886      );
    887    }
    888    return accumulator;
    889  }
    890  reduceRight(callback, ...opts) {
    891    assertFloat16Array(this);
    892    const float16bitsArray = getFloat16BitsArray(this);
    893    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    894    if (length === 0 && opts.length === 0) {
    895      throw NativeTypeError(REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE);
    896    }
    897    let accumulator, start;
    898    if (opts.length === 0) {
    899      accumulator = convertToNumber(float16bitsArray[length - 1]);
    900      start = length - 2;
    901    } else {
    902      accumulator = opts[0];
    903      start = length - 1;
    904    }
    905    for (let i = start; i >= 0; --i) {
    906      accumulator = callback(
    907        accumulator,
    908        convertToNumber(float16bitsArray[i]),
    909        i,
    910        this
    911      );
    912    }
    913    return accumulator;
    914  }
    915  forEach(callback, ...opts) {
    916    assertFloat16Array(this);
    917    const float16bitsArray = getFloat16BitsArray(this);
    918    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    919    const thisArg = opts[0];
    920    for (let i = 0; i < length; ++i) {
    921      ReflectApply(callback, thisArg, [
    922      convertToNumber(float16bitsArray[i]),
    923      i,
    924      this]
    925      );
    926    }
    927  }
    928  find(callback, ...opts) {
    929    assertFloat16Array(this);
    930    const float16bitsArray = getFloat16BitsArray(this);
    931    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    932    const thisArg = opts[0];
    933    for (let i = 0; i < length; ++i) {
    934      const value = convertToNumber(float16bitsArray[i]);
    935      if (ReflectApply(callback, thisArg, [value, i, this])) {
    936        return value;
    937      }
    938    }
    939  }
    940  findIndex(callback, ...opts) {
    941    assertFloat16Array(this);
    942    const float16bitsArray = getFloat16BitsArray(this);
    943    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    944    const thisArg = opts[0];
    945    for (let i = 0; i < length; ++i) {
    946      const value = convertToNumber(float16bitsArray[i]);
    947      if (ReflectApply(callback, thisArg, [value, i, this])) {
    948        return i;
    949      }
    950    }
    951    return -1;
    952  }
    953  findLast(callback, ...opts) {
    954    assertFloat16Array(this);
    955    const float16bitsArray = getFloat16BitsArray(this);
    956    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    957    const thisArg = opts[0];
    958    for (let i = length - 1; i >= 0; --i) {
    959      const value = convertToNumber(float16bitsArray[i]);
    960      if (ReflectApply(callback, thisArg, [value, i, this])) {
    961        return value;
    962      }
    963    }
    964  }
    965  findLastIndex(callback, ...opts) {
    966    assertFloat16Array(this);
    967    const float16bitsArray = getFloat16BitsArray(this);
    968    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    969    const thisArg = opts[0];
    970    for (let i = length - 1; i >= 0; --i) {
    971      const value = convertToNumber(float16bitsArray[i]);
    972      if (ReflectApply(callback, thisArg, [value, i, this])) {
    973        return i;
    974      }
    975    }
    976    return -1;
    977  }
    978  every(callback, ...opts) {
    979    assertFloat16Array(this);
    980    const float16bitsArray = getFloat16BitsArray(this);
    981    const length = TypedArrayPrototypeGetLength(float16bitsArray);
    982    const thisArg = opts[0];
    983    for (let i = 0; i < length; ++i) {
    984      if (
    985      !ReflectApply(callback, thisArg, [
    986      convertToNumber(float16bitsArray[i]),
    987      i,
    988      this]
    989      ))
    990      {
    991        return false;
    992      }
    993    }
    994    return true;
    995  }
    996  some(callback, ...opts) {
    997    assertFloat16Array(this);
    998    const float16bitsArray = getFloat16BitsArray(this);
    999    const length = TypedArrayPrototypeGetLength(float16bitsArray);
   1000    const thisArg = opts[0];
   1001    for (let i = 0; i < length; ++i) {
   1002      if (
   1003      ReflectApply(callback, thisArg, [
   1004      convertToNumber(float16bitsArray[i]),
   1005      i,
   1006      this]
   1007      ))
   1008      {
   1009        return true;
   1010      }
   1011    }
   1012    return false;
   1013  }
   1014  set(input, ...opts) {
   1015    assertFloat16Array(this);
   1016    const float16bitsArray = getFloat16BitsArray(this);
   1017    const targetOffset = ToIntegerOrInfinity(opts[0]);
   1018    if (targetOffset < 0) {
   1019      throw NativeRangeError(OFFSET_IS_OUT_OF_BOUNDS);
   1020    }
   1021    if (input == null) {
   1022      throw NativeTypeError(
   1023        CANNOT_CONVERT_UNDEFINED_OR_NULL_TO_OBJECT
   1024      );
   1025    }
   1026    if (isNativeBigIntTypedArray(input)) {
   1027      throw NativeTypeError(
   1028        CANNOT_MIX_BIGINT_AND_OTHER_TYPES
   1029      );
   1030    }
   1031    if (isFloat16Array(input)) {
   1032      return TypedArrayPrototypeSet(
   1033        getFloat16BitsArray(this),
   1034        getFloat16BitsArray(input),
   1035        targetOffset
   1036      );
   1037    }
   1038    if (isNativeTypedArray(input)) {
   1039      const buffer = TypedArrayPrototypeGetBuffer(input);
   1040      if (IsDetachedBuffer(buffer)) {
   1041        throw NativeTypeError(ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);
   1042      }
   1043    }
   1044    const targetLength = TypedArrayPrototypeGetLength(float16bitsArray);
   1045    const src = NativeObject(input);
   1046    const srcLength = ToLength(src.length);
   1047    if (targetOffset === Infinity || srcLength + targetOffset > targetLength) {
   1048      throw NativeRangeError(OFFSET_IS_OUT_OF_BOUNDS);
   1049    }
   1050    for (let i = 0; i < srcLength; ++i) {
   1051      float16bitsArray[i + targetOffset] = roundToFloat16Bits(src[i]);
   1052    }
   1053  }
   1054  reverse() {
   1055    assertFloat16Array(this);
   1056    const float16bitsArray = getFloat16BitsArray(this);
   1057    TypedArrayPrototypeReverse(float16bitsArray);
   1058    return this;
   1059  }
   1060  toReversed() {
   1061    assertFloat16Array(this);
   1062    const float16bitsArray = getFloat16BitsArray(this);
   1063    const uint16 = new NativeUint16Array(
   1064      TypedArrayPrototypeGetBuffer(float16bitsArray),
   1065      TypedArrayPrototypeGetByteOffset(float16bitsArray),
   1066      TypedArrayPrototypeGetLength(float16bitsArray)
   1067    );
   1068    const cloned = new Float16Array(
   1069      TypedArrayPrototypeGetBuffer(
   1070        TypedArrayPrototypeSlice(uint16)
   1071      )
   1072    );
   1073    const clonedFloat16bitsArray = getFloat16BitsArray(cloned);
   1074    TypedArrayPrototypeReverse(clonedFloat16bitsArray);
   1075    return cloned;
   1076  }
   1077  fill(value, ...opts) {
   1078    assertFloat16Array(this);
   1079    const float16bitsArray = getFloat16BitsArray(this);
   1080    TypedArrayPrototypeFill(
   1081      float16bitsArray,
   1082      roundToFloat16Bits(value),
   1083      ...safeIfNeeded(opts)
   1084    );
   1085    return this;
   1086  }
   1087  copyWithin(target, start, ...opts) {
   1088    assertFloat16Array(this);
   1089    const float16bitsArray = getFloat16BitsArray(this);
   1090    TypedArrayPrototypeCopyWithin(float16bitsArray, target, start, ...safeIfNeeded(opts));
   1091    return this;
   1092  }
   1093  sort(compareFn) {
   1094    assertFloat16Array(this);
   1095    const float16bitsArray = getFloat16BitsArray(this);
   1096    const sortCompare = compareFn !== undefined ? compareFn : defaultCompare;
   1097    TypedArrayPrototypeSort(float16bitsArray, (x, y) => {
   1098      return sortCompare(convertToNumber(x), convertToNumber(y));
   1099    });
   1100    return this;
   1101  }
   1102  toSorted(compareFn) {
   1103    assertFloat16Array(this);
   1104    const float16bitsArray = getFloat16BitsArray(this);
   1105    if (compareFn !== undefined && typeof compareFn !== "function") {
   1106      throw new NativeTypeError(THE_COMPARISON_FUNCTION_MUST_BE_EITHER_A_FUNCTION_OR_UNDEFINED);
   1107    }
   1108    const sortCompare = compareFn !== undefined ? compareFn : defaultCompare;
   1109    const uint16 = new NativeUint16Array(
   1110      TypedArrayPrototypeGetBuffer(float16bitsArray),
   1111      TypedArrayPrototypeGetByteOffset(float16bitsArray),
   1112      TypedArrayPrototypeGetLength(float16bitsArray)
   1113    );
   1114    const cloned = new Float16Array(
   1115      TypedArrayPrototypeGetBuffer(
   1116        TypedArrayPrototypeSlice(uint16)
   1117      )
   1118    );
   1119    const clonedFloat16bitsArray = getFloat16BitsArray(cloned);
   1120    TypedArrayPrototypeSort(clonedFloat16bitsArray, (x, y) => {
   1121      return sortCompare(convertToNumber(x), convertToNumber(y));
   1122    });
   1123    return cloned;
   1124  }
   1125  slice(start, end) {
   1126    assertFloat16Array(this);
   1127    const float16bitsArray = getFloat16BitsArray(this);
   1128    const Constructor = SpeciesConstructor(float16bitsArray, Float16Array);
   1129    if (Constructor === Float16Array) {
   1130      const uint16 = new NativeUint16Array(
   1131        TypedArrayPrototypeGetBuffer(float16bitsArray),
   1132        TypedArrayPrototypeGetByteOffset(float16bitsArray),
   1133        TypedArrayPrototypeGetLength(float16bitsArray)
   1134      );
   1135      return new Float16Array(
   1136        TypedArrayPrototypeGetBuffer(
   1137          TypedArrayPrototypeSlice(uint16, start, end)
   1138        )
   1139      );
   1140    }
   1141    const length = TypedArrayPrototypeGetLength(float16bitsArray);
   1142    const relativeStart = ToIntegerOrInfinity(start);
   1143    const relativeEnd = end === undefined ? length : ToIntegerOrInfinity(end);
   1144    let k;
   1145    if (relativeStart === -Infinity) {
   1146      k = 0;
   1147    } else if (relativeStart < 0) {
   1148      k = length + relativeStart > 0 ? length + relativeStart : 0;
   1149    } else {
   1150      k = length < relativeStart ? length : relativeStart;
   1151    }
   1152    let final;
   1153    if (relativeEnd === -Infinity) {
   1154      final = 0;
   1155    } else if (relativeEnd < 0) {
   1156      final = length + relativeEnd > 0 ? length + relativeEnd : 0;
   1157    } else {
   1158      final = length < relativeEnd ? length : relativeEnd;
   1159    }
   1160    const count = final - k > 0 ? final - k : 0;
   1161    const array = new Constructor(count);
   1162    assertSpeciesTypedArray(array, count);
   1163    if (count === 0) {
   1164      return array;
   1165    }
   1166    const buffer = TypedArrayPrototypeGetBuffer(float16bitsArray);
   1167    if (IsDetachedBuffer(buffer)) {
   1168      throw NativeTypeError(ATTEMPTING_TO_ACCESS_DETACHED_ARRAYBUFFER);
   1169    }
   1170    let n = 0;
   1171    while (k < final) {
   1172      array[n] = convertToNumber(float16bitsArray[k]);
   1173      ++k;
   1174      ++n;
   1175    }
   1176    return array;
   1177  }
   1178  subarray(begin, end) {
   1179    assertFloat16Array(this);
   1180    const float16bitsArray = getFloat16BitsArray(this);
   1181    const Constructor = SpeciesConstructor(float16bitsArray, Float16Array);
   1182    const uint16 = new NativeUint16Array(
   1183      TypedArrayPrototypeGetBuffer(float16bitsArray),
   1184      TypedArrayPrototypeGetByteOffset(float16bitsArray),
   1185      TypedArrayPrototypeGetLength(float16bitsArray)
   1186    );
   1187    const uint16Subarray = TypedArrayPrototypeSubarray(uint16, begin, end);
   1188    const array = new Constructor(
   1189      TypedArrayPrototypeGetBuffer(uint16Subarray),
   1190      TypedArrayPrototypeGetByteOffset(uint16Subarray),
   1191      TypedArrayPrototypeGetLength(uint16Subarray)
   1192    );
   1193    assertSpeciesTypedArray(array);
   1194    return array;
   1195  }
   1196  indexOf(element, ...opts) {
   1197    assertFloat16Array(this);
   1198    const float16bitsArray = getFloat16BitsArray(this);
   1199    const length = TypedArrayPrototypeGetLength(float16bitsArray);
   1200    let from = ToIntegerOrInfinity(opts[0]);
   1201    if (from === Infinity) {
   1202      return -1;
   1203    }
   1204    if (from < 0) {
   1205      from += length;
   1206      if (from < 0) {
   1207        from = 0;
   1208      }
   1209    }
   1210    for (let i = from; i < length; ++i) {
   1211      if (
   1212      ObjectHasOwn(float16bitsArray, i) &&
   1213      convertToNumber(float16bitsArray[i]) === element)
   1214      {
   1215        return i;
   1216      }
   1217    }
   1218    return -1;
   1219  }
   1220  lastIndexOf(element, ...opts) {
   1221    assertFloat16Array(this);
   1222    const float16bitsArray = getFloat16BitsArray(this);
   1223    const length = TypedArrayPrototypeGetLength(float16bitsArray);
   1224    let from = opts.length >= 1 ? ToIntegerOrInfinity(opts[0]) : length - 1;
   1225    if (from === -Infinity) {
   1226      return -1;
   1227    }
   1228    if (from >= 0) {
   1229      from = from < length - 1 ? from : length - 1;
   1230    } else {
   1231      from += length;
   1232    }
   1233    for (let i = from; i >= 0; --i) {
   1234      if (
   1235      ObjectHasOwn(float16bitsArray, i) &&
   1236      convertToNumber(float16bitsArray[i]) === element)
   1237      {
   1238        return i;
   1239      }
   1240    }
   1241    return -1;
   1242  }
   1243  includes(element, ...opts) {
   1244    assertFloat16Array(this);
   1245    const float16bitsArray = getFloat16BitsArray(this);
   1246    const length = TypedArrayPrototypeGetLength(float16bitsArray);
   1247    let from = ToIntegerOrInfinity(opts[0]);
   1248    if (from === Infinity) {
   1249      return false;
   1250    }
   1251    if (from < 0) {
   1252      from += length;
   1253      if (from < 0) {
   1254        from = 0;
   1255      }
   1256    }
   1257    const isNaN = NumberIsNaN(element);
   1258    for (let i = from; i < length; ++i) {
   1259      const value = convertToNumber(float16bitsArray[i]);
   1260      if (isNaN && NumberIsNaN(value)) {
   1261        return true;
   1262      }
   1263      if (value === element) {
   1264        return true;
   1265      }
   1266    }
   1267    return false;
   1268  }
   1269  join(separator) {
   1270    assertFloat16Array(this);
   1271    const float16bitsArray = getFloat16BitsArray(this);
   1272    const array = copyToArray(float16bitsArray);
   1273    return ArrayPrototypeJoin(array, separator);
   1274  }
   1275  toLocaleString(...opts) {
   1276    assertFloat16Array(this);
   1277    const float16bitsArray = getFloat16BitsArray(this);
   1278    const array = copyToArray(float16bitsArray);
   1279    return ArrayPrototypeToLocaleString(array, ...safeIfNeeded(opts));
   1280  }
   1281  get [SymbolToStringTag]() {
   1282    if (isFloat16Array(this)) {
   1283      return "Float16Array";
   1284    }
   1285  }
   1286 }
   1287 ObjectDefineProperty(Float16Array, "BYTES_PER_ELEMENT", {
   1288  value: BYTES_PER_ELEMENT
   1289 });
   1290 ObjectDefineProperty(Float16Array, brand, {});
   1291 ReflectSetPrototypeOf(Float16Array, TypedArray);
   1292 const Float16ArrayPrototype = Float16Array.prototype;
   1293 ObjectDefineProperty(Float16ArrayPrototype, "BYTES_PER_ELEMENT", {
   1294  value: BYTES_PER_ELEMENT
   1295 });
   1296 ObjectDefineProperty(Float16ArrayPrototype, SymbolIterator, {
   1297  value: Float16ArrayPrototype.values,
   1298  writable: true,
   1299  configurable: true
   1300 });
   1301 ReflectSetPrototypeOf(Float16ArrayPrototype, TypedArrayPrototype);
   1302 
   1303 function isTypedArray(target) {
   1304  return isNativeTypedArray(target) || isFloat16Array(target);
   1305 }
   1306 
   1307 function getFloat16(dataView, byteOffset, ...opts) {
   1308  return convertToNumber(
   1309    DataViewPrototypeGetUint16(dataView, byteOffset, ...safeIfNeeded(opts))
   1310  );
   1311 }
   1312 function setFloat16(dataView, byteOffset, value, ...opts) {
   1313  return DataViewPrototypeSetUint16(
   1314    dataView,
   1315    byteOffset,
   1316    roundToFloat16Bits(value),
   1317    ...safeIfNeeded(opts)
   1318  );
   1319 }
   1320 
   1321 function f16round(x) {
   1322  return roundToFloat16(x);
   1323 }
   1324 
   1325 export { Float16Array, f16round, getFloat16, f16round as hfround, isFloat16Array, isTypedArray, setFloat16 };