Skip to content

Latest commit

 

History

History
651 lines (635 loc) · 22.8 KB

File metadata and controls

651 lines (635 loc) · 22.8 KB

es2020.bigint.d.ts Diffs

Index: es2020.bigint.d.ts
===================================================================
--- es2020.bigint.d.ts
+++ es2020.bigint.d.ts
@@ -263,24 +263,24 @@
   copyWithin(target: number, start: number, end?: number): this;
 
   /** Yields index, value pairs for every entry in the array. */
   entries(): ArrayIterator<[number, bigint]>;
-
   /**
    * Determines whether all the members of an array satisfy the specified test.
    * @param predicate A function that accepts up to three arguments. The every method calls
    * the predicate function for each element in the array until the predicate returns false,
    * or until the end of the array.
    * @param thisArg An object to which the this keyword can refer in the predicate function.
    * If thisArg is omitted, undefined is used as the this value.
    */
-  every(
+  every<This = undefined>(
     predicate: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigInt64Array<TArrayBuffer>,
+      array: this,
     ) => boolean,
-    thisArg?: any,
+    thisArg?: This,
   ): boolean;
 
   /**
    * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
@@ -290,25 +290,24 @@
    * @param end index to stop filling the array at. If end is negative, it is treated as
    * length+end.
    */
   fill(value: bigint, start?: number, end?: number): this;
-
   /**
    * Returns the elements of an array that meet the condition specified in a callback function.
    * @param predicate A function that accepts up to three arguments. The filter method calls
    * the predicate function one time for each element in the array.
    * @param thisArg An object to which the this keyword can refer in the predicate function.
    * If thisArg is omitted, undefined is used as the this value.
    */
-  filter(
+  filter<This = undefined>(
     predicate: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigInt64Array<TArrayBuffer>,
-    ) => any,
-    thisArg?: any,
-  ): BigInt64Array<ArrayBuffer>;
-
+      array: this,
+    ) => boolean,
+    thisArg?: This,
+  ): BigInt64Array;
   /**
    * Returns the value of the first element in the array where predicate is true, and undefined
    * otherwise.
    * @param predicate find calls predicate once for each element of the array, in ascending
@@ -316,17 +315,17 @@
    * immediately returns that element value. Otherwise, find returns undefined.
    * @param thisArg If provided, it will be used as the this value for each invocation of
    * predicate. If it is not provided, undefined is used instead.
    */
-  find(
+  find<This = undefined>(
     predicate: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigInt64Array<TArrayBuffer>,
+      array: this,
     ) => boolean,
-    thisArg?: any,
+    thisArg?: This,
   ): bigint | undefined;
-
   /**
    * Returns the index of the first element in the array where predicate is true, and -1
    * otherwise.
    * @param predicate find calls predicate once for each element of the array, in ascending
@@ -334,31 +333,27 @@
    * findIndex immediately returns that element index. Otherwise, findIndex returns -1.
    * @param thisArg If provided, it will be used as the this value for each invocation of
    * predicate. If it is not provided, undefined is used instead.
    */
-  findIndex(
+  findIndex<This = undefined>(
     predicate: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigInt64Array<TArrayBuffer>,
+      array: this,
     ) => boolean,
-    thisArg?: any,
+    thisArg?: This,
   ): number;
-
   /**
    * Performs the specified action for each element in an array.
    * @param callbackfn A function that accepts up to three arguments. forEach calls the
    * callbackfn function one time for each element in the array.
    * @param thisArg An object to which the this keyword can refer in the callbackfn function.
    * If thisArg is omitted, undefined is used as the this value.
    */
-  forEach(
-    callbackfn: (
-      value: bigint,
-      index: number,
-      array: BigInt64Array<TArrayBuffer>,
-    ) => void,
-    thisArg?: any,
+  forEach<This = undefined>(
+    callbackfn: (this: This, value: bigint, index: number, array: this) => void,
+    thisArg?: This,
   ): void;
 
   /**
    * Determines whether an array includes a certain element, returning true or false as appropriate.
@@ -394,45 +389,40 @@
   lastIndexOf(searchElement: bigint, fromIndex?: number): number;
 
   /** The length of the array. */
   readonly length: number;
-
   /**
    * Calls a defined callback function on each element of an array, and returns an array that
    * contains the results.
    * @param callbackfn A function that accepts up to three arguments. The map method calls the
    * callbackfn function one time for each element in the array.
    * @param thisArg An object to which the this keyword can refer in the callbackfn function.
    * If thisArg is omitted, undefined is used as the this value.
    */
-  map(
+  map<This = undefined>(
     callbackfn: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigInt64Array<TArrayBuffer>,
+      array: this,
     ) => bigint,
-    thisArg?: any,
-  ): BigInt64Array<ArrayBuffer>;
-
+    thisArg?: This,
+  ): BigInt64Array;
   /**
    * Calls the specified callback function for all the elements in an array. The return value of
    * the callback function is the accumulated result, and is provided as an argument in the next
    * call to the callback function.
    * @param callbackfn A function that accepts up to four arguments. The reduce method calls the
    * callbackfn function one time for each element in the array.
-   * @param initialValue If initialValue is specified, it is used as the initial value to start
-   * the accumulation. The first call to the callbackfn function provides this value as an argument
-   * instead of an array value.
    */
-  reduce(
+  reduce<U = bigint>(
     callbackfn: (
-      previousValue: bigint,
+      previousValue: bigint | U,
       currentValue: bigint,
       currentIndex: number,
-      array: BigInt64Array<TArrayBuffer>,
-    ) => bigint,
-  ): bigint;
-
+      array: this,
+    ) => U,
+  ): bigint | U;
   /**
    * Calls the specified callback function for all the elements in an array. The return value of
    * the callback function is the accumulated result, and is provided as an argument in the next
    * call to the callback function.
@@ -441,37 +431,32 @@
    * @param initialValue If initialValue is specified, it is used as the initial value to start
    * the accumulation. The first call to the callbackfn function provides this value as an argument
    * instead of an array value.
    */
-  reduce<U>(
+  reduce<U = bigint>(
     callbackfn: (
       previousValue: U,
       currentValue: bigint,
       currentIndex: number,
-      array: BigInt64Array<TArrayBuffer>,
+      array: this,
     ) => U,
     initialValue: U,
   ): U;
-
   /**
    * Calls the specified callback function for all the elements in an array, in descending order.
    * The return value of the callback function is the accumulated result, and is provided as an
    * argument in the next call to the callback function.
    * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
    * the callbackfn function one time for each element in the array.
-   * @param initialValue If initialValue is specified, it is used as the initial value to start
-   * the accumulation. The first call to the callbackfn function provides this value as an
-   * argument instead of an array value.
    */
-  reduceRight(
+  reduceRight<U = bigint>(
     callbackfn: (
-      previousValue: bigint,
+      previousValue: bigint | U,
       currentValue: bigint,
       currentIndex: number,
-      array: BigInt64Array<TArrayBuffer>,
-    ) => bigint,
-  ): bigint;
-
+      array: this,
+    ) => U,
+  ): bigint | U;
   /**
    * Calls the specified callback function for all the elements in an array, in descending order.
    * The return value of the callback function is the accumulated result, and is provided as an
    * argument in the next call to the callback function.
@@ -480,14 +465,14 @@
    * @param initialValue If initialValue is specified, it is used as the initial value to start
    * the accumulation. The first call to the callbackfn function provides this value as an argument
    * instead of an array value.
    */
-  reduceRight<U>(
+  reduceRight<U = bigint>(
     callbackfn: (
       previousValue: U,
       currentValue: bigint,
       currentIndex: number,
-      array: BigInt64Array<TArrayBuffer>,
+      array: this,
     ) => U,
     initialValue: U,
   ): U;
 
@@ -506,24 +491,24 @@
    * @param start The beginning of the specified portion of the array.
    * @param end The end of the specified portion of the array.
    */
   slice(start?: number, end?: number): BigInt64Array<ArrayBuffer>;
-
   /**
    * Determines whether the specified callback function returns true for any element of an array.
    * @param predicate A function that accepts up to three arguments. The some method calls the
    * predicate function for each element in the array until the predicate returns true, or until
    * the end of the array.
    * @param thisArg An object to which the this keyword can refer in the predicate function.
    * If thisArg is omitted, undefined is used as the this value.
    */
-  some(
+  some<This = undefined>(
     predicate: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigInt64Array<TArrayBuffer>,
+      array: this,
     ) => boolean,
-    thisArg?: any,
+    thisArg?: This,
   ): boolean;
 
   /**
    * Sorts the array.
@@ -583,43 +568,25 @@
    * Returns a new array from a set of elements.
    * @param items A set of elements to include in the new array object.
    */
   of(...items: bigint[]): BigInt64Array<ArrayBuffer>;
-
   /**
    * Creates an array from an array-like or iterable object.
-   * @param arrayLike An array-like object to convert to an array.
+   * @param arrayLike An array-like or iterable object to convert to an array.
    */
-  from(arrayLike: ArrayLike<bigint>): BigInt64Array<ArrayBuffer>;
-
-  /**
-   * Creates an array from an array-like or iterable object.
-   * @param arrayLike An array-like object to convert to an array.
-   * @param mapfn A mapping function to call on every element of the array.
-   * @param thisArg Value of 'this' used to invoke the mapfn.
-   */
-  from<U>(
-    arrayLike: ArrayLike<U>,
-    mapfn: (v: U, k: number) => bigint,
-    thisArg?: any,
+  from(
+    arrayLike: Iterable<bigint> | ArrayLike<bigint>,
   ): BigInt64Array<ArrayBuffer>;
-
   /**
    * Creates an array from an array-like or iterable object.
-   * @param elements An iterable object to convert to an array.
-   */
-  from(elements: Iterable<bigint>): BigInt64Array<ArrayBuffer>;
-
-  /**
-   * Creates an array from an array-like or iterable object.
-   * @param elements An iterable object to convert to an array.
+   * @param arrayLike An array-like or iterable object to convert to an array.
    * @param mapfn A mapping function to call on every element of the array.
    * @param thisArg Value of 'this' used to invoke the mapfn.
    */
-  from<T>(
-    elements: Iterable<T>,
-    mapfn?: (v: T, k: number) => bigint,
-    thisArg?: any,
+  from<T, This = undefined>(
+    arrayLike: Iterable<T> | ArrayLike<T>,
+    mapfn: (this: This, v: T, k: number) => bigint,
+    thisArg?: This,
   ): BigInt64Array<ArrayBuffer>;
 }
 declare var BigInt64Array: BigInt64ArrayConstructor;
 
@@ -654,24 +621,24 @@
   copyWithin(target: number, start: number, end?: number): this;
 
   /** Yields index, value pairs for every entry in the array. */
   entries(): ArrayIterator<[number, bigint]>;
-
   /**
    * Determines whether all the members of an array satisfy the specified test.
    * @param predicate A function that accepts up to three arguments. The every method calls
    * the predicate function for each element in the array until the predicate returns false,
    * or until the end of the array.
    * @param thisArg An object to which the this keyword can refer in the predicate function.
    * If thisArg is omitted, undefined is used as the this value.
    */
-  every(
+  every<This = undefined>(
     predicate: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigUint64Array<TArrayBuffer>,
+      array: this,
     ) => boolean,
-    thisArg?: any,
+    thisArg?: This,
   ): boolean;
 
   /**
    * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
@@ -681,25 +648,24 @@
    * @param end index to stop filling the array at. If end is negative, it is treated as
    * length+end.
    */
   fill(value: bigint, start?: number, end?: number): this;
-
   /**
    * Returns the elements of an array that meet the condition specified in a callback function.
    * @param predicate A function that accepts up to three arguments. The filter method calls
    * the predicate function one time for each element in the array.
    * @param thisArg An object to which the this keyword can refer in the predicate function.
    * If thisArg is omitted, undefined is used as the this value.
    */
-  filter(
+  filter<This = undefined>(
     predicate: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigUint64Array<TArrayBuffer>,
-    ) => any,
-    thisArg?: any,
-  ): BigUint64Array<ArrayBuffer>;
-
+      array: this,
+    ) => boolean,
+    thisArg?: This,
+  ): BigUint64Array;
   /**
    * Returns the value of the first element in the array where predicate is true, and undefined
    * otherwise.
    * @param predicate find calls predicate once for each element of the array, in ascending
@@ -707,17 +673,17 @@
    * immediately returns that element value. Otherwise, find returns undefined.
    * @param thisArg If provided, it will be used as the this value for each invocation of
    * predicate. If it is not provided, undefined is used instead.
    */
-  find(
+  find<This = undefined>(
     predicate: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigUint64Array<TArrayBuffer>,
+      array: this,
     ) => boolean,
-    thisArg?: any,
+    thisArg?: This,
   ): bigint | undefined;
-
   /**
    * Returns the index of the first element in the array where predicate is true, and -1
    * otherwise.
    * @param predicate find calls predicate once for each element of the array, in ascending
@@ -725,31 +691,27 @@
    * findIndex immediately returns that element index. Otherwise, findIndex returns -1.
    * @param thisArg If provided, it will be used as the this value for each invocation of
    * predicate. If it is not provided, undefined is used instead.
    */
-  findIndex(
+  findIndex<This = undefined>(
     predicate: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigUint64Array<TArrayBuffer>,
+      array: this,
     ) => boolean,
-    thisArg?: any,
+    thisArg?: This,
   ): number;
-
   /**
    * Performs the specified action for each element in an array.
    * @param callbackfn A function that accepts up to three arguments. forEach calls the
    * callbackfn function one time for each element in the array.
    * @param thisArg An object to which the this keyword can refer in the callbackfn function.
    * If thisArg is omitted, undefined is used as the this value.
    */
-  forEach(
-    callbackfn: (
-      value: bigint,
-      index: number,
-      array: BigUint64Array<TArrayBuffer>,
-    ) => void,
-    thisArg?: any,
+  forEach<This = undefined>(
+    callbackfn: (this: This, value: bigint, index: number, array: this) => void,
+    thisArg?: This,
   ): void;
 
   /**
    * Determines whether an array includes a certain element, returning true or false as appropriate.
@@ -785,45 +747,40 @@
   lastIndexOf(searchElement: bigint, fromIndex?: number): number;
 
   /** The length of the array. */
   readonly length: number;
-
   /**
    * Calls a defined callback function on each element of an array, and returns an array that
    * contains the results.
    * @param callbackfn A function that accepts up to three arguments. The map method calls the
    * callbackfn function one time for each element in the array.
    * @param thisArg An object to which the this keyword can refer in the callbackfn function.
    * If thisArg is omitted, undefined is used as the this value.
    */
-  map(
+  map<This = undefined>(
     callbackfn: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigUint64Array<TArrayBuffer>,
+      array: this,
     ) => bigint,
-    thisArg?: any,
-  ): BigUint64Array<ArrayBuffer>;
-
+    thisArg?: This,
+  ): BigUint64Array;
   /**
    * Calls the specified callback function for all the elements in an array. The return value of
    * the callback function is the accumulated result, and is provided as an argument in the next
    * call to the callback function.
    * @param callbackfn A function that accepts up to four arguments. The reduce method calls the
    * callbackfn function one time for each element in the array.
-   * @param initialValue If initialValue is specified, it is used as the initial value to start
-   * the accumulation. The first call to the callbackfn function provides this value as an argument
-   * instead of an array value.
    */
-  reduce(
+  reduce<U = bigint>(
     callbackfn: (
-      previousValue: bigint,
+      previousValue: bigint | U,
       currentValue: bigint,
       currentIndex: number,
-      array: BigUint64Array<TArrayBuffer>,
-    ) => bigint,
-  ): bigint;
-
+      array: this,
+    ) => U,
+  ): bigint | U;
   /**
    * Calls the specified callback function for all the elements in an array. The return value of
    * the callback function is the accumulated result, and is provided as an argument in the next
    * call to the callback function.
@@ -832,37 +789,32 @@
    * @param initialValue If initialValue is specified, it is used as the initial value to start
    * the accumulation. The first call to the callbackfn function provides this value as an argument
    * instead of an array value.
    */
-  reduce<U>(
+  reduce<U = bigint>(
     callbackfn: (
       previousValue: U,
       currentValue: bigint,
       currentIndex: number,
-      array: BigUint64Array<TArrayBuffer>,
+      array: this,
     ) => U,
     initialValue: U,
   ): U;
-
   /**
    * Calls the specified callback function for all the elements in an array, in descending order.
    * The return value of the callback function is the accumulated result, and is provided as an
    * argument in the next call to the callback function.
    * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls
    * the callbackfn function one time for each element in the array.
-   * @param initialValue If initialValue is specified, it is used as the initial value to start
-   * the accumulation. The first call to the callbackfn function provides this value as an
-   * argument instead of an array value.
    */
-  reduceRight(
+  reduceRight<U = bigint>(
     callbackfn: (
-      previousValue: bigint,
+      previousValue: bigint | U,
       currentValue: bigint,
       currentIndex: number,
-      array: BigUint64Array<TArrayBuffer>,
-    ) => bigint,
-  ): bigint;
-
+      array: this,
+    ) => U,
+  ): bigint | U;
   /**
    * Calls the specified callback function for all the elements in an array, in descending order.
    * The return value of the callback function is the accumulated result, and is provided as an
    * argument in the next call to the callback function.
@@ -871,14 +823,14 @@
    * @param initialValue If initialValue is specified, it is used as the initial value to start
    * the accumulation. The first call to the callbackfn function provides this value as an argument
    * instead of an array value.
    */
-  reduceRight<U>(
+  reduceRight<U = bigint>(
     callbackfn: (
       previousValue: U,
       currentValue: bigint,
       currentIndex: number,
-      array: BigUint64Array<TArrayBuffer>,
+      array: this,
     ) => U,
     initialValue: U,
   ): U;
 
@@ -897,24 +849,24 @@
    * @param start The beginning of the specified portion of the array.
    * @param end The end of the specified portion of the array.
    */
   slice(start?: number, end?: number): BigUint64Array<ArrayBuffer>;
-
   /**
    * Determines whether the specified callback function returns true for any element of an array.
    * @param predicate A function that accepts up to three arguments. The some method calls the
    * predicate function for each element in the array until the predicate returns true, or until
    * the end of the array.
    * @param thisArg An object to which the this keyword can refer in the predicate function.
    * If thisArg is omitted, undefined is used as the this value.
    */
-  some(
+  some<This = undefined>(
     predicate: (
+      this: This,
       value: bigint,
       index: number,
-      array: BigUint64Array<TArrayBuffer>,
+      array: this,
     ) => boolean,
-    thisArg?: any,
+    thisArg?: This,
   ): boolean;
 
   /**
    * Sorts the array.
@@ -976,43 +928,25 @@
    * Returns a new array from a set of elements.
    * @param items A set of elements to include in the new array object.
    */
   of(...items: bigint[]): BigUint64Array<ArrayBuffer>;
-
   /**
    * Creates an array from an array-like or iterable object.
-   * @param arrayLike An array-like object to convert to an array.
+   * @param arrayLike An array-like or iterable object to convert to an array.
    */
-  from(arrayLike: ArrayLike<bigint>): BigUint64Array<ArrayBuffer>;
-
-  /**
-   * Creates an array from an array-like or iterable object.
-   * @param arrayLike An array-like object to convert to an array.
-   * @param mapfn A mapping function to call on every element of the array.
-   * @param thisArg Value of 'this' used to invoke the mapfn.
-   */
-  from<U>(
-    arrayLike: ArrayLike<U>,
-    mapfn: (v: U, k: number) => bigint,
-    thisArg?: any,
+  from(
+    arrayLike: Iterable<bigint> | ArrayLike<bigint>,
   ): BigUint64Array<ArrayBuffer>;
-
   /**
    * Creates an array from an array-like or iterable object.
-   * @param elements An iterable object to convert to an array.
-   */
-  from(elements: Iterable<bigint>): BigUint64Array<ArrayBuffer>;
-
-  /**
-   * Creates an array from an array-like or iterable object.
-   * @param elements An iterable object to convert to an array.
+   * @param arrayLike An array-like or iterable object to convert to an array.
    * @param mapfn A mapping function to call on every element of the array.
    * @param thisArg Value of 'this' used to invoke the mapfn.
    */
-  from<T>(
-    elements: Iterable<T>,
-    mapfn?: (v: T, k: number) => bigint,
-    thisArg?: any,
+  from<T, This = undefined>(
+    arrayLike: Iterable<T> | ArrayLike<T>,
+    mapfn: (this: This, v: T, k: number) => bigint,
+    thisArg?: This,
   ): BigUint64Array<ArrayBuffer>;
 }
 declare var BigUint64Array: BigUint64ArrayConstructor;