tor-browser

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

float16.d.ts (17930B)


      1 /**
      2 * A typed array of 16-bit float values. The contents are initialized to 0. If the requested number
      3 * of bytes could not be allocated an exception is raised.
      4 */
      5 export interface Float16Array {
      6  /**
      7   * The size in bytes of each element in the array.
      8   */
      9  readonly BYTES_PER_ELEMENT: number;
     10 
     11  /**
     12   * The ArrayBuffer instance referenced by the array.
     13   */
     14  readonly buffer: ArrayBufferLike;
     15 
     16  /**
     17   * The length in bytes of the array.
     18   */
     19  readonly byteLength: number;
     20 
     21  /**
     22   * The offset in bytes of the array.
     23   */
     24  readonly byteOffset: number;
     25 
     26  [Symbol.iterator](): IterableIterator<number>;
     27 
     28  /**
     29   * Returns an array of key, value pairs for every entry in the array
     30   */
     31  entries(): IterableIterator<[number, number]>;
     32 
     33  /**
     34   * Returns an list of keys in the array
     35   */
     36  keys(): IterableIterator<number>;
     37 
     38  /**
     39   * Returns an list of values in the array
     40   */
     41  values(): IterableIterator<number>;
     42 
     43  /**
     44   * Returns the item located at the specified index.
     45   * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
     46   */
     47  at(index: number): number | undefined;
     48 
     49  /**
     50   * Returns the this object after copying a section of the array identified by start and end
     51   * to the same array starting at position target
     52   * @param target If target is negative, it is treated as length+target where length is the
     53   * length of the array.
     54   * @param start If start is negative, it is treated as length+start. If end is negative, it
     55   * is treated as length+end.
     56   * @param end If not specified, length of the this object is used as its default value.
     57   */
     58  copyWithin(target: number, start: number, end?: number): this;
     59 
     60  /**
     61   * Determines whether all the members of an array satisfy the specified test.
     62   * @param callbackfn A function that accepts up to three arguments. The every method calls
     63   * the callbackfn function for each element in the array until the callbackfn returns a value
     64   * which is coercible to the Boolean value false, or until the end of the array.
     65   * @param thisArg An object to which the this keyword can refer in the callbackfn function.
     66   * If thisArg is omitted, undefined is used as the this value.
     67   */
     68  every(
     69    callbackfn: (value: number, index: number, array: Float16Array) => unknown,
     70    thisArg?: any,
     71  ): boolean;
     72 
     73  /**
     74   * Returns the this object after filling the section identified by start and end with value
     75   * @param value value to fill array section with
     76   * @param start index to start filling the array at. If start is negative, it is treated as
     77   * length+start where length is the length of the array.
     78   * @param end index to stop filling the array at. If end is negative, it is treated as
     79   * length+end.
     80   */
     81  fill(value: number, start?: number, end?: number): this;
     82 
     83  /**
     84   * Returns the elements of an array that meet the condition specified in a callback function.
     85   * @param predicate A function that accepts up to three arguments. The filter method calls
     86   * the predicate function one time for each element in the array.
     87   * @param thisArg An object to which the this keyword can refer in the predicate function.
     88   * If thisArg is omitted, undefined is used as the this value.
     89   */
     90  filter(
     91    predicate: (value: number, index: number, array: Float16Array) => any,
     92    thisArg?: any,
     93  ): Float16Array;
     94 
     95  /**
     96   * Returns the value of the first element in the array where predicate is true, and undefined
     97   * otherwise.
     98   * @param predicate find calls predicate once for each element of the array, in ascending
     99   * order, until it finds one where predicate returns true. If such an element is found, find
    100   * immediately returns that element value. Otherwise, find returns undefined.
    101   * @param thisArg If provided, it will be used as the this value for each invocation of
    102   * predicate. If it is not provided, undefined is used instead.
    103   */
    104  find(
    105    predicate: (value: number, index: number, obj: Float16Array) => boolean,
    106    thisArg?: any,
    107  ): number | undefined;
    108 
    109  /**
    110   * Returns the index of the first element in the array where predicate is true, and -1
    111   * otherwise.
    112   * @param predicate find calls predicate once for each element of the array, in ascending
    113   * order, until it finds one where predicate returns true. If such an element is found,
    114   * findIndex immediately returns that element index. Otherwise, findIndex returns -1.
    115   * @param thisArg If provided, it will be used as the this value for each invocation of
    116   * predicate. If it is not provided, undefined is used instead.
    117   */
    118  findIndex(
    119    predicate: (value: number, index: number, obj: Float16Array) => boolean,
    120    thisArg?: any,
    121  ): number;
    122 
    123  /**
    124   * Returns the value of the last element in the array where predicate is true, and undefined
    125   * otherwise.
    126   * @param predicate find calls predicate once for each element of the array, in descending
    127   * order, until it finds one where predicate returns true. If such an element is found, findLast
    128   * immediately returns that element value. Otherwise, findLast returns undefined.
    129   * @param thisArg If provided, it will be used as the this value for each invocation of
    130   * predicate. If it is not provided, undefined is used instead.
    131   */
    132  findLast(
    133    predicate: (value: number, index: number, obj: Float16Array) => boolean,
    134    thisArg?: any,
    135  ): number | undefined;
    136 
    137  /**
    138   * Returns the index of the last element in the array where predicate is true, and -1
    139   * otherwise.
    140   * @param predicate find calls predicate once for each element of the array, in descending
    141   * order, until it finds one where predicate returns true. If such an element is found,
    142   * findLastIndex immediately returns that element index. Otherwise, findLastIndex returns -1.
    143   * @param thisArg If provided, it will be used as the this value for each invocation of
    144   * predicate. If it is not provided, undefined is used instead.
    145   */
    146  findLastIndex(
    147    predicate: (value: number, index: number, obj: Float16Array) => boolean,
    148    thisArg?: any,
    149  ): number;
    150 
    151  /**
    152   * Performs the specified action for each element in an array.
    153   * @param callbackfn A function that accepts up to three arguments. forEach calls the
    154   * callbackfn function one time for each element in the array.
    155   * @param thisArg An object to which the this keyword can refer in the callbackfn function.
    156   * If thisArg is omitted, undefined is used as the this value.
    157   */
    158  forEach(
    159    callbackfn: (value: number, index: number, array: Float16Array) => void,
    160    thisArg?: any,
    161  ): void;
    162 
    163  /**
    164   * Determines whether an array includes a certain element, returning true or false as appropriate.
    165   * @param searchElement The element to search for.
    166   * @param fromIndex The position in this array at which to begin searching for searchElement.
    167   */
    168  includes(searchElement: number, fromIndex?: number): boolean;
    169 
    170  /**
    171   * Returns the index of the first occurrence of a value in an array.
    172   * @param searchElement The value to locate in the array.
    173   * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
    174   * search starts at index 0.
    175   */
    176  indexOf(searchElement: number, fromIndex?: number): number;
    177 
    178  /**
    179   * Adds all the elements of an array separated by the specified separator string.
    180   * @param separator A string used to separate one element of an array from the next in the
    181   * resulting String. If omitted, the array elements are separated with a comma.
    182   */
    183  join(separator?: string): string;
    184 
    185  /**
    186   * Returns the index of the last occurrence of a value in an array.
    187   * @param searchElement The value to locate in the array.
    188   * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
    189   * search starts at index 0.
    190   */
    191  lastIndexOf(searchElement: number, fromIndex?: number): number;
    192 
    193  /**
    194   * The length of the array.
    195   */
    196  readonly length: number;
    197 
    198  /**
    199   * Calls a defined callback function on each element of an array, and returns an array that
    200   * contains the results.
    201   * @param callbackfn A function that accepts up to three arguments. The map method calls the
    202   * callbackfn function one time for each element in the array.
    203   * @param thisArg An object to which the this keyword can refer in the callbackfn function.
    204   * If thisArg is omitted, undefined is used as the this value.
    205   */
    206  map(
    207    callbackfn: (value: number, index: number, array: Float16Array) => number,
    208    thisArg?: any,
    209  ): Float16Array;
    210 
    211  /**
    212   * Calls the specified callback function for all the elements in an array. The return value of
    213   * the callback function is the accumulated result, and is provided as an argument in the next
    214   * call to the callback function.
    215   * @param callbackfn A function that accepts up to four arguments. The reduce method calls the
    216   * callbackfn function one time for each element in the array.
    217   * @param initialValue If initialValue is specified, it is used as the initial value to start
    218   * the accumulation. The first call to the callbackfn function provides this value as an argument
    219   * instead of an array value.
    220   */
    221  reduce(
    222    callbackfn: (
    223      previousValue: number,
    224      currentValue: number,
    225      currentIndex: number,
    226      array: Float16Array,
    227    ) => number,
    228  ): number;
    229  reduce(
    230    callbackfn: (
    231      previousValue: number,
    232      currentValue: number,
    233      currentIndex: number,
    234      array: Float16Array,
    235    ) => number,
    236    initialValue: number,
    237  ): number;
    238  reduce<U>(
    239    callbackfn: (
    240      previousValue: U,
    241      currentValue: number,
    242      currentIndex: number,
    243      array: Float16Array,
    244    ) => U,
    245    initialValue: U,
    246  ): U;
    247 
    248  /**
    249   * Calls the specified callback function for all the elements in an array, in descending order.
    250   * The return value of the callback function is the accumulated result, and is provided as an
    251   * argument in the next call to the callback function.
    252   * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
    253   * the callbackfn function one time for each element in the array.
    254   * @param initialValue If initialValue is specified, it is used as the initial value to start
    255   * the accumulation. The first call to the callbackfn function provides this value as an
    256   * argument instead of an array value.
    257   */
    258  reduceRight(
    259    callbackfn: (
    260      previousValue: number,
    261      currentValue: number,
    262      currentIndex: number,
    263      array: Float16Array,
    264    ) => number,
    265  ): number;
    266  reduceRight(
    267    callbackfn: (
    268      previousValue: number,
    269      currentValue: number,
    270      currentIndex: number,
    271      array: Float16Array,
    272    ) => number,
    273    initialValue: number,
    274  ): number;
    275  reduceRight<U>(
    276    callbackfn: (
    277      previousValue: U,
    278      currentValue: number,
    279      currentIndex: number,
    280      array: Float16Array,
    281    ) => U,
    282    initialValue: U,
    283  ): U;
    284 
    285  /**
    286   * Reverses the elements in an Array.
    287   */
    288  reverse(): this;
    289 
    290  /**
    291   * Sets a value or an array of values.
    292   * @param array A typed or untyped array of values to set.
    293   * @param offset The index in the current array at which the values are to be written.
    294   */
    295  set(array: ArrayLike<number>, offset?: number): void;
    296 
    297  /**
    298   * Returns a section of an array.
    299   * @param start The beginning of the specified portion of the array.
    300   * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
    301   */
    302  slice(start?: number, end?: number): Float16Array;
    303 
    304  /**
    305   * Determines whether the specified callback function returns true for any element of an array.
    306   * @param callbackfn A function that accepts up to three arguments. The some method calls
    307   * the callbackfn function for each element in the array until the callbackfn returns a value
    308   * which is coercible to the Boolean value true, or until the end of the array.
    309   * @param thisArg An object to which the this keyword can refer in the callbackfn function.
    310   * If thisArg is omitted, undefined is used as the this value.
    311   */
    312  some(
    313    callbackfn: (value: number, index: number, array: Float16Array) => unknown,
    314    thisArg?: any,
    315  ): boolean;
    316 
    317  /**
    318   * Sorts an array.
    319   * @param compareFn Function used to determine the order of the elements. It is expected to return
    320   * a negative value if first argument is less than second argument, zero if they're equal and a positive
    321   * value otherwise. If omitted, the elements are sorted in ascending.
    322   */
    323  sort(compareFn?: (a: number, b: number) => number): this;
    324 
    325  /**
    326   * Gets a new Float16Array view of the ArrayBuffer store for this array, referencing the elements
    327   * at begin, inclusive, up to end, exclusive.
    328   * @param begin The index of the beginning of the array.
    329   * @param end The index of the end of the array.
    330   */
    331  subarray(begin?: number, end?: number): Float16Array;
    332 
    333  /**
    334   * Copies the array and returns the copy with the elements in reverse order.
    335   */
    336  toReversed(): Float16Array;
    337 
    338  /**
    339   * Copies and sorts the array.
    340   * @param compareFn Function used to determine the order of the elements. It is expected to return
    341   * a negative value if first argument is less than second argument, zero if they're equal and a positive
    342   * value otherwise. If omitted, the elements are sorted in ascending.
    343   */
    344  toSorted(compareFn?: (a: number, b: number) => number): Float16Array;
    345 
    346  /**
    347   * Copies the array and replaces the element at the given index with the provided value.
    348   * @param index The zero-based location in the array for which to replace an element.
    349   * @param value Element to insert into the array in place of the replaced element.
    350   */
    351  with(index: number, value: number): Float16Array;
    352 
    353  /**
    354   * Converts a number to a string by using the current locale.
    355   */
    356  toLocaleString(): string;
    357 
    358  /**
    359   * Returns a string representation of an array.
    360   */
    361  toString(): string;
    362 
    363  /**
    364   * Returns the primitive value of the specified object.
    365   */
    366  valueOf(): Float16Array;
    367 
    368  readonly [Symbol.toStringTag]: "Float16Array";
    369 
    370  [index: number]: number;
    371 }
    372 
    373 export interface Float16ArrayConstructor {
    374  readonly prototype: Float16Array;
    375  new (): Float16Array;
    376  new (length: number): Float16Array;
    377  new (elements: Iterable<number>): Float16Array;
    378  new (array: ArrayLike<number> | ArrayBufferLike): Float16Array;
    379  new (
    380    buffer: ArrayBufferLike,
    381    byteOffset: number,
    382    length?: number,
    383  ): Float16Array;
    384 
    385  /**
    386   * The size in bytes of each element in the array.
    387   */
    388  readonly BYTES_PER_ELEMENT: number;
    389 
    390  /**
    391   * Returns a new array from a set of elements.
    392   * @param items A set of elements to include in the new array object.
    393   */
    394  of(...items: number[]): Float16Array;
    395 
    396  /**
    397   * Creates an array from an array-like or iterable object.
    398   * @param elements An iterable object to convert to an array.
    399   */
    400  from(elements: Iterable<number>): Float16Array;
    401 
    402  /**
    403   * Creates an array from an array-like or iterable object.
    404   * @param elements An iterable object to convert to an array.
    405   * @param mapfn A mapping function to call on every element of the array.
    406   * @param thisArg Value of 'this' used to invoke the mapfn.
    407   */
    408  from<T>(
    409    elements: Iterable<T>,
    410    mapfn: (v: T, k: number) => number,
    411    thisArg?: any,
    412  ): Float16Array;
    413 
    414  /**
    415   * Creates an array from an array-like or iterable object.
    416   * @param arrayLike An array-like object to convert to an array.
    417   */
    418  from(arrayLike: ArrayLike<number>): Float16Array;
    419 
    420  /**
    421   * Creates an array from an array-like or iterable object.
    422   * @param arrayLike An array-like object to convert to an array.
    423   * @param mapfn A mapping function to call on every element of the array.
    424   * @param thisArg Value of 'this' used to invoke the mapfn.
    425   */
    426  from<T>(
    427    arrayLike: ArrayLike<T>,
    428    mapfn: (v: T, k: number) => number,
    429    thisArg?: any,
    430  ): Float16Array;
    431 }
    432 export declare const Float16Array: Float16ArrayConstructor;
    433 
    434 /**
    435 * Returns `true` if the value is a Float16Array instance.
    436 * @since v3.4.0
    437 */
    438 export declare function isFloat16Array(value: unknown): value is Float16Array;
    439 
    440 /**
    441 * Returns `true` if the value is a type of TypedArray instance that contains  Float16Array.
    442 * @since v3.6.0
    443 */
    444 export declare function isTypedArray(
    445  value: unknown,
    446 ): value is
    447  | Uint8Array
    448  | Uint8ClampedArray
    449  | Uint16Array
    450  | Uint32Array
    451  | Int8Array
    452  | Int16Array
    453  | Int32Array
    454  | Float16Array
    455  | Float32Array
    456  | Float64Array
    457  | BigUint64Array
    458  | BigInt64Array;
    459 
    460 /**
    461 * Gets the Float16 value at the specified byte offset from the start of the view. There is
    462 * no alignment constraint; multi-byte values may be fetched from any offset.
    463 * @param byteOffset The place in the buffer at which the value should be retrieved.
    464 * @param littleEndian If false or undefined, a big-endian value should be read,
    465 * otherwise a little-endian value should be read.
    466 */
    467 export declare function getFloat16(
    468  dataView: DataView,
    469  byteOffset: number,
    470  littleEndian?: boolean,
    471 ): number;
    472 
    473 /**
    474 * Stores an Float16 value at the specified byte offset from the start of the view.
    475 * @param byteOffset The place in the buffer at which the value should be set.
    476 * @param value The value to set.
    477 * @param littleEndian If false or undefined, a big-endian value should be written,
    478 * otherwise a little-endian value should be written.
    479 */
    480 export declare function setFloat16(
    481  dataView: DataView,
    482  byteOffset: number,
    483  value: number,
    484  littleEndian?: boolean,
    485 ): void;
    486 
    487 /**
    488 * Returns the nearest half-precision float representation of a number.
    489 * @param x A numeric expression.
    490 */
    491 export declare function f16round(x: number): number;
    492 
    493 /**
    494 * Returns the nearest half-precision float representation of a number.
    495 * @alias f16round
    496 * @param x A numeric expression.
    497 */
    498 export declare function hfround(x: number): number;