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
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.
12 See the Apache Version 2.0 License for specific language governing permissions
13 and limitations under the License.
14 ***************************************************************************** */
18 /// <reference no-default-lib="true"/>
23 * Returns a string representation of an object.
24 * @param radix Specifies a radix for converting numeric values to strings.
26 toString(radix?: number): string;
28 /** Returns a string representation appropriate to the host environment's current locale. */
29 toLocaleString(): string;
31 /** Returns the primitive value of the specified object. */
34 readonly [Symbol.toStringTag]: "BigInt";
37 interface BigIntConstructor {
38 (value?: any): bigint;
39 readonly prototype: BigInt;
42 * Interprets the low bits of a BigInt as a 2's-complement signed integer.
43 * All higher bits are discarded.
44 * @param bits The number of low bits to use
45 * @param int The BigInt whose bits to extract
47 asIntN(bits: number, int: bigint): bigint;
49 * Interprets the low bits of a BigInt as an unsigned integer.
50 * All higher bits are discarded.
51 * @param bits The number of low bits to use
52 * @param int The BigInt whose bits to extract
54 asUintN(bits: number, int: bigint): bigint;
57 declare var BigInt: BigIntConstructor;
60 * A typed array of 64-bit signed integer values. The contents are initialized to 0. If the
61 * requested number of bytes could not be allocated, an exception is raised.
63 interface BigInt64Array {
64 /** The size in bytes of each element in the array. */
65 readonly BYTES_PER_ELEMENT: number;
67 /** The ArrayBuffer instance referenced by the array. */
68 readonly buffer: ArrayBufferLike;
70 /** The length in bytes of the array. */
71 readonly byteLength: number;
73 /** The offset in bytes of the array. */
74 readonly byteOffset: number;
77 * Returns the this object after copying a section of the array identified by start and end
78 * to the same array starting at position target
79 * @param target If target is negative, it is treated as length+target where length is the
80 * length of the array.
81 * @param start If start is negative, it is treated as length+start. If end is negative, it
82 * is treated as length+end.
83 * @param end If not specified, length of the this object is used as its default value.
85 copyWithin(target: number, start: number, end?: number): this;
87 /** Yields index, value pairs for every entry in the array. */
88 entries(): IterableIterator<[number, bigint]>;
91 * Determines whether all the members of an array satisfy the specified test.
92 * @param callbackfn A function that accepts up to three arguments. The every method calls
93 * the callbackfn function for each element in the array until the callbackfn returns false,
94 * or until the end of the array.
95 * @param thisArg An object to which the this keyword can refer in the callbackfn function.
96 * If thisArg is omitted, undefined is used as the this value.
98 every(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean;
101 * Returns the this object after filling the section identified by start and end with value
102 * @param value value to fill array section with
103 * @param start index to start filling the array at. If start is negative, it is treated as
104 * length+start where length is the length of the array.
105 * @param end index to stop filling the array at. If end is negative, it is treated as
108 fill(value: bigint, start?: number, end?: number): this;
111 * Returns the elements of an array that meet the condition specified in a callback function.
112 * @param callbackfn A function that accepts up to three arguments. The filter method calls
113 * the callbackfn function one time for each element in the array.
114 * @param thisArg An object to which the this keyword can refer in the callbackfn function.
115 * If thisArg is omitted, undefined is used as the this value.
117 filter(callbackfn: (value: bigint, index: number, array: BigInt64Array) => any, thisArg?: any): BigInt64Array;
120 * Returns the value of the first element in the array where predicate is true, and undefined
122 * @param predicate find calls predicate once for each element of the array, in ascending
123 * order, until it finds one where predicate returns true. If such an element is found, find
124 * immediately returns that element value. Otherwise, find returns undefined.
125 * @param thisArg If provided, it will be used as the this value for each invocation of
126 * predicate. If it is not provided, undefined is used instead.
128 find(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): bigint | undefined;
131 * Returns the index of the first element in the array where predicate is true, and -1
133 * @param predicate find calls predicate once for each element of the array, in ascending
134 * order, until it finds one where predicate returns true. If such an element is found,
135 * findIndex immediately returns that element index. Otherwise, findIndex returns -1.
136 * @param thisArg If provided, it will be used as the this value for each invocation of
137 * predicate. If it is not provided, undefined is used instead.
139 findIndex(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): number;
142 * Performs the specified action for each element in an array.
143 * @param callbackfn A function that accepts up to three arguments. forEach calls the
144 * callbackfn function one time for each element in the array.
145 * @param thisArg An object to which the this keyword can refer in the callbackfn function.
146 * If thisArg is omitted, undefined is used as the this value.
148 forEach(callbackfn: (value: bigint, index: number, array: BigInt64Array) => void, thisArg?: any): void;
151 * Determines whether an array includes a certain element, returning true or false as appropriate.
152 * @param searchElement The element to search for.
153 * @param fromIndex The position in this array at which to begin searching for searchElement.
155 includes(searchElement: bigint, fromIndex?: number): boolean;
158 * Returns the index of the first occurrence of a value in an array.
159 * @param searchElement The value to locate in the array.
160 * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
161 * search starts at index 0.
163 indexOf(searchElement: bigint, fromIndex?: number): number;
166 * Adds all the elements of an array separated by the specified separator string.
167 * @param separator A string used to separate one element of an array from the next in the
168 * resulting String. If omitted, the array elements are separated with a comma.
170 join(separator?: string): string;
172 /** Yields each index in the array. */
173 keys(): IterableIterator<number>;
176 * Returns the index of the last 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.
181 lastIndexOf(searchElement: bigint, fromIndex?: number): number;
183 /** The length of the array. */
184 readonly length: number;
187 * Calls a defined callback function on each element of an array, and returns an array that
188 * contains the results.
189 * @param callbackfn A function that accepts up to three arguments. The map method calls the
190 * callbackfn function one time for each element in the array.
191 * @param thisArg An object to which the this keyword can refer in the callbackfn function.
192 * If thisArg is omitted, undefined is used as the this value.
194 map(callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, thisArg?: any): BigInt64Array;
197 * Calls the specified callback function for all the elements in an array. The return value of
198 * the callback function is the accumulated result, and is provided as an argument in the next
199 * call to the callback function.
200 * @param callbackfn A function that accepts up to four arguments. The reduce method calls the
201 * callbackfn function one time for each element in the array.
202 * @param initialValue If initialValue is specified, it is used as the initial value to start
203 * the accumulation. The first call to the callbackfn function provides this value as an argument
204 * instead of an array value.
206 reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint;
209 * Calls the specified callback function for all the elements in an array. The return value of
210 * the callback function is the accumulated result, and is provided as an argument in the next
211 * call to the callback function.
212 * @param callbackfn A function that accepts up to four arguments. The reduce method calls the
213 * callbackfn function one time for each element in the array.
214 * @param initialValue If initialValue is specified, it is used as the initial value to start
215 * the accumulation. The first call to the callbackfn function provides this value as an argument
216 * instead of an array value.
218 reduce<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U;
221 * Calls the specified callback function for all the elements in an array, in descending order.
222 * The return value of the callback function is the accumulated result, and is provided as an
223 * argument in the next call to the callback function.
224 * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
225 * the callbackfn function one time for each element in the array.
226 * @param initialValue If initialValue is specified, it is used as the initial value to start
227 * the accumulation. The first call to the callbackfn function provides this value as an
228 * argument instead of an array value.
230 reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint;
233 * Calls the specified callback function for all the elements in an array, in descending order.
234 * The return value of the callback function is the accumulated result, and is provided as an
235 * argument in the next call to the callback function.
236 * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
237 * the callbackfn function one time for each element in the array.
238 * @param initialValue If initialValue is specified, it is used as the initial value to start
239 * the accumulation. The first call to the callbackfn function provides this value as an argument
240 * instead of an array value.
242 reduceRight<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U;
244 /** Reverses the elements in the array. */
248 * Sets a value or an array of values.
249 * @param array A typed or untyped array of values to set.
250 * @param offset The index in the current array at which the values are to be written.
252 set(array: ArrayLike<bigint>, offset?: number): void;
255 * Returns a section of an array.
256 * @param start The beginning of the specified portion of the array.
257 * @param end The end of the specified portion of the array.
259 slice(start?: number, end?: number): BigInt64Array;
262 * Determines whether the specified callback function returns true for any element of an array.
263 * @param callbackfn A function that accepts up to three arguments. The some method calls the
264 * callbackfn function for each element in the array until the callbackfn returns true, or until
265 * the end of the array.
266 * @param thisArg An object to which the this keyword can refer in the callbackfn function.
267 * If thisArg is omitted, undefined is used as the this value.
269 some(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean;
273 * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order.
275 sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this;
278 * Gets a new BigInt64Array view of the ArrayBuffer store for this array, referencing the elements
279 * at begin, inclusive, up to end, exclusive.
280 * @param begin The index of the beginning of the array.
281 * @param end The index of the end of the array.
283 subarray(begin: number, end?: number): BigInt64Array;
285 /** Converts the array to a string by using the current locale. */
286 toLocaleString(): string;
288 /** Returns a string representation of the array. */
291 /** Yields each value in the array. */
292 values(): IterableIterator<bigint>;
294 [Symbol.iterator](): IterableIterator<bigint>;
296 readonly [Symbol.toStringTag]: "BigInt64Array";
298 [index: number]: bigint;
301 interface BigInt64ArrayConstructor {
302 readonly prototype: BigInt64Array;
303 new(length?: number): BigInt64Array;
304 new(array: Iterable<bigint>): BigInt64Array;
305 new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigInt64Array;
307 /** The size in bytes of each element in the array. */
308 readonly BYTES_PER_ELEMENT: number;
311 * Returns a new array from a set of elements.
312 * @param items A set of elements to include in the new array object.
314 of(...items: bigint[]): BigInt64Array;
317 * Creates an array from an array-like or iterable object.
318 * @param arrayLike An array-like or iterable object to convert to an array.
319 * @param mapfn A mapping function to call on every element of the array.
320 * @param thisArg Value of 'this' used to invoke the mapfn.
322 from(arrayLike: ArrayLike<bigint>): BigInt64Array;
323 from<U>(arrayLike: ArrayLike<U>, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array;
326 declare var BigInt64Array: BigInt64ArrayConstructor;
329 * A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the
330 * requested number of bytes could not be allocated, an exception is raised.
332 interface BigUint64Array {
333 /** The size in bytes of each element in the array. */
334 readonly BYTES_PER_ELEMENT: number;
336 /** The ArrayBuffer instance referenced by the array. */
337 readonly buffer: ArrayBufferLike;
339 /** The length in bytes of the array. */
340 readonly byteLength: number;
342 /** The offset in bytes of the array. */
343 readonly byteOffset: number;
346 * Returns the this object after copying a section of the array identified by start and end
347 * to the same array starting at position target
348 * @param target If target is negative, it is treated as length+target where length is the
349 * length of the array.
350 * @param start If start is negative, it is treated as length+start. If end is negative, it
351 * is treated as length+end.
352 * @param end If not specified, length of the this object is used as its default value.
354 copyWithin(target: number, start: number, end?: number): this;
356 /** Yields index, value pairs for every entry in the array. */
357 entries(): IterableIterator<[number, bigint]>;
360 * Determines whether all the members of an array satisfy the specified test.
361 * @param callbackfn A function that accepts up to three arguments. The every method calls
362 * the callbackfn function for each element in the array until the callbackfn returns false,
363 * or until the end of the array.
364 * @param thisArg An object to which the this keyword can refer in the callbackfn function.
365 * If thisArg is omitted, undefined is used as the this value.
367 every(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean;
370 * Returns the this object after filling the section identified by start and end with value
371 * @param value value to fill array section with
372 * @param start index to start filling the array at. If start is negative, it is treated as
373 * length+start where length is the length of the array.
374 * @param end index to stop filling the array at. If end is negative, it is treated as
377 fill(value: bigint, start?: number, end?: number): this;
380 * Returns the elements of an array that meet the condition specified in a callback function.
381 * @param callbackfn A function that accepts up to three arguments. The filter method calls
382 * the callbackfn function one time for each element in the array.
383 * @param thisArg An object to which the this keyword can refer in the callbackfn function.
384 * If thisArg is omitted, undefined is used as the this value.
386 filter(callbackfn: (value: bigint, index: number, array: BigUint64Array) => any, thisArg?: any): BigUint64Array;
389 * Returns the value of the first element in the array where predicate is true, and undefined
391 * @param predicate find calls predicate once for each element of the array, in ascending
392 * order, until it finds one where predicate returns true. If such an element is found, find
393 * immediately returns that element value. Otherwise, find returns undefined.
394 * @param thisArg If provided, it will be used as the this value for each invocation of
395 * predicate. If it is not provided, undefined is used instead.
397 find(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): bigint | undefined;
400 * Returns the index of the first element in the array where predicate is true, and -1
402 * @param predicate find calls predicate once for each element of the array, in ascending
403 * order, until it finds one where predicate returns true. If such an element is found,
404 * findIndex immediately returns that element index. Otherwise, findIndex returns -1.
405 * @param thisArg If provided, it will be used as the this value for each invocation of
406 * predicate. If it is not provided, undefined is used instead.
408 findIndex(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): number;
411 * Performs the specified action for each element in an array.
412 * @param callbackfn A function that accepts up to three arguments. forEach calls the
413 * callbackfn function one time for each element in the array.
414 * @param thisArg An object to which the this keyword can refer in the callbackfn function.
415 * If thisArg is omitted, undefined is used as the this value.
417 forEach(callbackfn: (value: bigint, index: number, array: BigUint64Array) => void, thisArg?: any): void;
420 * Determines whether an array includes a certain element, returning true or false as appropriate.
421 * @param searchElement The element to search for.
422 * @param fromIndex The position in this array at which to begin searching for searchElement.
424 includes(searchElement: bigint, fromIndex?: number): boolean;
427 * Returns the index of the first occurrence of a value in an array.
428 * @param searchElement The value to locate in the array.
429 * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
430 * search starts at index 0.
432 indexOf(searchElement: bigint, fromIndex?: number): number;
435 * Adds all the elements of an array separated by the specified separator string.
436 * @param separator A string used to separate one element of an array from the next in the
437 * resulting String. If omitted, the array elements are separated with a comma.
439 join(separator?: string): string;
441 /** Yields each index in the array. */
442 keys(): IterableIterator<number>;
445 * Returns the index of the last occurrence of a value in an array.
446 * @param searchElement The value to locate in the array.
447 * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
448 * search starts at index 0.
450 lastIndexOf(searchElement: bigint, fromIndex?: number): number;
452 /** The length of the array. */
453 readonly length: number;
456 * Calls a defined callback function on each element of an array, and returns an array that
457 * contains the results.
458 * @param callbackfn A function that accepts up to three arguments. The map method calls the
459 * callbackfn function one time for each element in the array.
460 * @param thisArg An object to which the this keyword can refer in the callbackfn function.
461 * If thisArg is omitted, undefined is used as the this value.
463 map(callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, thisArg?: any): BigUint64Array;
466 * Calls the specified callback function for all the elements in an array. The return value of
467 * the callback function is the accumulated result, and is provided as an argument in the next
468 * call to the callback function.
469 * @param callbackfn A function that accepts up to four arguments. The reduce method calls the
470 * callbackfn function one time for each element in the array.
471 * @param initialValue If initialValue is specified, it is used as the initial value to start
472 * the accumulation. The first call to the callbackfn function provides this value as an argument
473 * instead of an array value.
475 reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint;
478 * Calls the specified callback function for all the elements in an array. The return value of
479 * the callback function is the accumulated result, and is provided as an argument in the next
480 * call to the callback function.
481 * @param callbackfn A function that accepts up to four arguments. The reduce method calls the
482 * callbackfn function one time for each element in the array.
483 * @param initialValue If initialValue is specified, it is used as the initial value to start
484 * the accumulation. The first call to the callbackfn function provides this value as an argument
485 * instead of an array value.
487 reduce<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U;
490 * Calls the specified callback function for all the elements in an array, in descending order.
491 * The return value of the callback function is the accumulated result, and is provided as an
492 * argument in the next call to the callback function.
493 * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
494 * the callbackfn function one time for each element in the array.
495 * @param initialValue If initialValue is specified, it is used as the initial value to start
496 * the accumulation. The first call to the callbackfn function provides this value as an
497 * argument instead of an array value.
499 reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint;
502 * Calls the specified callback function for all the elements in an array, in descending order.
503 * The return value of the callback function is the accumulated result, and is provided as an
504 * argument in the next call to the callback function.
505 * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
506 * the callbackfn function one time for each element in the array.
507 * @param initialValue If initialValue is specified, it is used as the initial value to start
508 * the accumulation. The first call to the callbackfn function provides this value as an argument
509 * instead of an array value.
511 reduceRight<U>(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U;
513 /** Reverses the elements in the array. */
517 * Sets a value or an array of values.
518 * @param array A typed or untyped array of values to set.
519 * @param offset The index in the current array at which the values are to be written.
521 set(array: ArrayLike<bigint>, offset?: number): void;
524 * Returns a section of an array.
525 * @param start The beginning of the specified portion of the array.
526 * @param end The end of the specified portion of the array.
528 slice(start?: number, end?: number): BigUint64Array;
531 * Determines whether the specified callback function returns true for any element of an array.
532 * @param callbackfn A function that accepts up to three arguments. The some method calls the
533 * callbackfn function for each element in the array until the callbackfn returns true, or until
534 * the end of the array.
535 * @param thisArg An object to which the this keyword can refer in the callbackfn function.
536 * If thisArg is omitted, undefined is used as the this value.
538 some(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean;
542 * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order.
544 sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this;
547 * Gets a new BigUint64Array view of the ArrayBuffer store for this array, referencing the elements
548 * at begin, inclusive, up to end, exclusive.
549 * @param begin The index of the beginning of the array.
550 * @param end The index of the end of the array.
552 subarray(begin: number, end?: number): BigUint64Array;
554 /** Converts the array to a string by using the current locale. */
555 toLocaleString(): string;
557 /** Returns a string representation of the array. */
560 /** Yields each value in the array. */
561 values(): IterableIterator<bigint>;
563 [Symbol.iterator](): IterableIterator<bigint>;
565 readonly [Symbol.toStringTag]: "BigUint64Array";
567 [index: number]: bigint;
570 interface BigUint64ArrayConstructor {
571 readonly prototype: BigUint64Array;
572 new(length?: number): BigUint64Array;
573 new(array: Iterable<bigint>): BigUint64Array;
574 new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigUint64Array;
576 /** The size in bytes of each element in the array. */
577 readonly BYTES_PER_ELEMENT: number;
580 * Returns a new array from a set of elements.
581 * @param items A set of elements to include in the new array object.
583 of(...items: bigint[]): BigUint64Array;
586 * Creates an array from an array-like or iterable object.
587 * @param arrayLike An array-like or iterable object to convert to an array.
588 * @param mapfn A mapping function to call on every element of the array.
589 * @param thisArg Value of 'this' used to invoke the mapfn.
591 from(arrayLike: ArrayLike<bigint>): BigUint64Array;
592 from<U>(arrayLike: ArrayLike<U>, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array;
595 declare var BigUint64Array: BigUint64ArrayConstructor;
599 * Gets the BigInt64 value at the specified byte offset from the start of the view. There is
600 * no alignment constraint; multi-byte values may be fetched from any offset.
601 * @param byteOffset The place in the buffer at which the value should be retrieved.
603 getBigInt64(byteOffset: number, littleEndian?: boolean): bigint;
606 * Gets the BigUint64 value at the specified byte offset from the start of the view. There is
607 * no alignment constraint; multi-byte values may be fetched from any offset.
608 * @param byteOffset The place in the buffer at which the value should be retrieved.
610 getBigUint64(byteOffset: number, littleEndian?: boolean): bigint;
613 * Stores a BigInt64 value at the specified byte offset from the start of the view.
614 * @param byteOffset The place in the buffer at which the value should be set.
615 * @param value The value to set.
616 * @param littleEndian If false or undefined, a big-endian value should be written,
617 * otherwise a little-endian value should be written.
619 setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
622 * Stores a BigUint64 value at the specified byte offset from the start of the view.
623 * @param byteOffset The place in the buffer at which the value should be set.
624 * @param value The value to set.
625 * @param littleEndian If false or undefined, a big-endian value should be written,
626 * otherwise a little-endian value should be written.
628 setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void;