Skip to content

Latest commit

 

History

History
593 lines (577 loc) · 21.4 KB

es2020.bigint.d.ts.md

File metadata and controls

593 lines (577 loc) · 21.4 KB

es2020.bigint.d.ts Diffs

Index: es2020.bigint.d.ts
===================================================================
--- es2020.bigint.d.ts
+++ es2020.bigint.d.ts
@@ -261,20 +261,24 @@
   copyWithin(target: number, start: number, end?: number): this;
 
   /** Yields index, value pairs for every entry in the array. */
   entries(): IterableIterator<[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(
-    predicate: (value: bigint, index: number, array: BigInt64Array) => boolean,
-    thisArg?: any,
+  every<This = undefined>(
+    predicate: (
+      this: This,
+      value: bigint,
+      index: number,
+      array: this,
+    ) => boolean,
+    thisArg?: This,
   ): boolean;
 
   /**
    * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
@@ -284,21 +288,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(
-    predicate: (value: bigint, index: number, array: BigInt64Array) => any,
-    thisArg?: any,
+  filter<This = undefined>(
+    predicate: (
+      this: This,
+      value: bigint,
+      index: number,
+      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
@@ -306,13 +313,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(
-    predicate: (value: bigint, index: number, array: BigInt64Array) => boolean,
-    thisArg?: any,
+  find<This = undefined>(
+    predicate: (
+      this: This,
+      value: bigint,
+      index: number,
+      array: this,
+    ) => boolean,
+    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
@@ -320,23 +331,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(
-    predicate: (value: bigint, index: number, array: BigInt64Array) => boolean,
-    thisArg?: any,
+  findIndex<This = undefined>(
+    predicate: (
+      this: This,
+      value: bigint,
+      index: number,
+      array: this,
+    ) => boolean,
+    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) => 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.
@@ -372,41 +387,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(
-    callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint,
-    thisArg?: any,
+  map<This = undefined>(
+    callbackfn: (
+      this: This,
+      value: bigint,
+      index: number,
+      array: this,
+    ) => bigint,
+    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,
-    ) => 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.
@@ -415,37 +429,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,
+      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,
-    ) => 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.
@@ -454,14 +463,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,
+      array: this,
     ) => U,
     initialValue: U,
   ): U;
 
@@ -480,20 +489,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;
-
   /**
    * 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(
-    predicate: (value: bigint, index: number, array: BigInt64Array) => boolean,
-    thisArg?: any,
+  some<This = undefined>(
+    predicate: (
+      this: This,
+      value: bigint,
+      index: number,
+      array: this,
+    ) => boolean,
+    thisArg?: This,
   ): boolean;
 
   /**
    * Sorts the array.
@@ -545,20 +558,23 @@
    * 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;
-
   /**
    * Creates an array from an array-like or iterable object.
    * @param arrayLike An array-like or iterable object to convert to an array.
+   */
+  from(arrayLike: Iterable<bigint> | ArrayLike<bigint>): BigInt64Array;
+  /**
+   * Creates an array from an array-like or iterable object.
+   * @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(arrayLike: ArrayLike<bigint>): BigInt64Array;
-  from<U>(
-    arrayLike: ArrayLike<U>,
-    mapfn: (v: U, 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;
 }
 
 declare var BigInt64Array: BigInt64ArrayConstructor;
@@ -592,20 +608,24 @@
   copyWithin(target: number, start: number, end?: number): this;
 
   /** Yields index, value pairs for every entry in the array. */
   entries(): IterableIterator<[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(
-    predicate: (value: bigint, index: number, array: BigUint64Array) => boolean,
-    thisArg?: any,
+  every<This = undefined>(
+    predicate: (
+      this: This,
+      value: bigint,
+      index: number,
+      array: this,
+    ) => boolean,
+    thisArg?: This,
   ): boolean;
 
   /**
    * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
@@ -615,21 +635,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(
-    predicate: (value: bigint, index: number, array: BigUint64Array) => any,
-    thisArg?: any,
+  filter<This = undefined>(
+    predicate: (
+      this: This,
+      value: bigint,
+      index: number,
+      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
@@ -637,13 +660,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(
-    predicate: (value: bigint, index: number, array: BigUint64Array) => boolean,
-    thisArg?: any,
+  find<This = undefined>(
+    predicate: (
+      this: This,
+      value: bigint,
+      index: number,
+      array: this,
+    ) => boolean,
+    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
@@ -651,23 +678,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(
-    predicate: (value: bigint, index: number, array: BigUint64Array) => boolean,
-    thisArg?: any,
+  findIndex<This = undefined>(
+    predicate: (
+      this: This,
+      value: bigint,
+      index: number,
+      array: this,
+    ) => boolean,
+    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) => 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.
@@ -703,41 +734,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(
-    callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint,
-    thisArg?: any,
+  map<This = undefined>(
+    callbackfn: (
+      this: This,
+      value: bigint,
+      index: number,
+      array: this,
+    ) => bigint,
+    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,
-    ) => 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.
@@ -746,37 +776,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,
+      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,
-    ) => 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.
@@ -785,14 +810,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,
+      array: this,
     ) => U,
     initialValue: U,
   ): U;
 
@@ -811,20 +836,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;
-
   /**
    * 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(
-    predicate: (value: bigint, index: number, array: BigUint64Array) => boolean,
-    thisArg?: any,
+  some<This = undefined>(
+    predicate: (
+      this: This,
+      value: bigint,
+      index: number,
+      array: this,
+    ) => boolean,
+    thisArg?: This,
   ): boolean;
 
   /**
    * Sorts the array.
@@ -876,20 +905,23 @@
    * 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;
-
   /**
    * Creates an array from an array-like or iterable object.
    * @param arrayLike An array-like or iterable object to convert to an array.
+   */
+  from(arrayLike: Iterable<bigint> | ArrayLike<bigint>): BigUint64Array;
+  /**
+   * Creates an array from an array-like or iterable object.
+   * @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(arrayLike: ArrayLike<bigint>): BigUint64Array;
-  from<U>(
-    arrayLike: ArrayLike<U>,
-    mapfn: (v: U, 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;
 }
 
 declare var BigUint64Array: BigUint64ArrayConstructor;