githrun

A CLI tool to run Python scrip...
Log | Files | Refs | README | LICENSE

lib.esnext.float16.d.ts (20528B)


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