CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

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