From df75aae96935aee290768f8e2b26d3d6c1104663 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Mon, 31 Oct 2022 18:55:37 -0500 Subject: [PATCH 01/18] feat(lib/esnext): add change array by copy types --- src/lib/esnext.d.ts | 2 + src/lib/esnext.typedarrays.d.ts | 311 ++++++++++++++++++++++++++++++++ src/lib/lib.esnext.array.d.ts | 100 ++++++++++ 3 files changed, 413 insertions(+) create mode 100644 src/lib/esnext.typedarrays.d.ts create mode 100644 src/lib/lib.esnext.array.d.ts diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index 6735ced8f7367..5641de99ba80e 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -1,2 +1,4 @@ /// /// +/// +/// diff --git a/src/lib/esnext.typedarrays.d.ts b/src/lib/esnext.typedarrays.d.ts new file mode 100644 index 0000000000000..f1037c695f11e --- /dev/null +++ b/src/lib/esnext.typedarrays.d.ts @@ -0,0 +1,311 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +interface Uint8Array { + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Uint8Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Uint8Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint8Array; +} + +interface Uint8ClampedArray { + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Uint8ClampedArray; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Uint8ClampedArray.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint8ClampedArray(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint8ClampedArray; +} + +interface Int8Array { + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Int8Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Int8Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int8Array(4) [-22, 1, 2, 11] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Int8Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Int8Array; +} + +interface Uint16Array { + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Uint16Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Uint16Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint16Array(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint16Array; +} + +interface Int16Array { + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Int16Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Int16Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int16Array(4) [-22, 1, 2, 11] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Int16Array; +} + +interface Uint32Array { + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Uint32Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Uint32Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint32Array(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint32Array; +} + +interface Int32Array { + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Int32Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Int32Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Int32Array; +} + +interface Float32Array { + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Float32Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Float32Array.from([11.25, 2, -22.5, 1]); + * myNums.toSorted((a, b) => a - b) // Float32Array(4) [-22.5, 1, 2, 11.5] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Float32Array; +} + +interface Float64Array { + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Float64Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Float64Array.from([11.25, 2, -22.5, 1]); + * myNums.toSorted((a, b) => a - b) // Float64Array(4) [-22.5, 1, 2, 11.5] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Float64Array; +} + +interface BigUint64Array { + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): BigUint64Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = BigUint64Array.from([11n, 2n, 22n, 1n]); + * myNums.toSorted((a, b) => Number(a - b)) // BigUint64Array(4) [1n, 2n, 11n, 22n] + * ``` + */ + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; + + /** + * Copies the array and inserts the given bigint at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: bigint): BigUint64Array; +} + +interface BigInt64Array { + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): BigInt64Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = BigInt64Array.from([11n, 2n, -22n, 1n]); + * myNums.toSorted((a, b) => Number(a - b)) // BigInt64Array(4) [-22n, 1n, 2n, 11n] + * ``` + */ + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; + + /** + * Copies the array and inserts the given bigint at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: bigint): BigInt64Array; +} diff --git a/src/lib/lib.esnext.array.d.ts b/src/lib/lib.esnext.array.d.ts new file mode 100644 index 0000000000000..766c228fec12b --- /dev/null +++ b/src/lib/lib.esnext.array.d.ts @@ -0,0 +1,100 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +interface Array { + /** + * Copies the array and returns the copied array with all of its elements reversed. + */ + toReversed(): T[]; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Copies an array and removes elements while, if necessary, inserting new elements in their place, returning the remaining elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + * @returns A copy of the original array with the remaining elements. + */ + toSpliced(start: number, deleteCount: number, ...items: F[]): (T | F)[]; + + /** + * Copies an array and removes elements while returning the remaining elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @returns A copy of the original array with the remaining elements. + */ + toSpliced(start: number, deleteCount?: number): T[]; + + /** + * Copies the array and inserts the given value at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: F): (T | F)[]; +} + +interface ReadonlyArray { + /** + * Copies the array and returns the copied array with all of its elements reversed. + */ + toReversed(): T[]; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Copies an array and removes elements while, if necessary, inserting new elements in their place, returning the remaining elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + * @returns A copy of the original array with the remaining elements. + */ + toSpliced(start: number, deleteCount: number, ...items: F[]): (T | F)[]; + + /** + * Copies an array and removes elements while returning the remaining elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @returns A copy of the original array with the remaining elements. + */ + toSpliced(start: number, deleteCount?: number): T[]; + + /** + * Copies the array and inserts the given value at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: F): (T | F)[]; +} From 1afc8ebe248e1810482160da55251852a07aaf38 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 1 Nov 2022 09:58:35 -0500 Subject: [PATCH 02/18] Update src/lib/esnext.typedarrays.d.ts --- src/lib/esnext.typedarrays.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/esnext.typedarrays.d.ts b/src/lib/esnext.typedarrays.d.ts index f1037c695f11e..176d697853554 100644 --- a/src/lib/esnext.typedarrays.d.ts +++ b/src/lib/esnext.typedarrays.d.ts @@ -79,8 +79,8 @@ interface Int8Array { * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. * ```ts - * const myNums = Int8Array.from([11, 2, -22, 1]); - * myNums.toSorted((a, b) => a - b) // Int8Array(4) [-22, 1, 2, 11] + * const myNums = Uint8ClampedArray.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint8ClampedArray(4) [1, 2, 11, 22] * ``` */ toSorted(compareFn?: (a: number, b: number) => number): Int8Array; From 454377192ced3ec34068af6ff39d243ed94f653a Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 1 Nov 2022 10:00:35 -0500 Subject: [PATCH 03/18] Update src/lib/esnext.typedarrays.d.ts --- src/lib/esnext.typedarrays.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/esnext.typedarrays.d.ts b/src/lib/esnext.typedarrays.d.ts index 176d697853554..0933e67e1ed2a 100644 --- a/src/lib/esnext.typedarrays.d.ts +++ b/src/lib/esnext.typedarrays.d.ts @@ -79,8 +79,9 @@ interface Int8Array { * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. * ```ts - * const myNums = Uint8ClampedArray.from([11, 2, 22, 1]); - * myNums.toSorted((a, b) => a - b) // Uint8ClampedArray(4) [1, 2, 11, 22] + * const myNums = Int8Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int8Array(4) [-22, 1, 2, 11] + * ``` */ toSorted(compareFn?: (a: number, b: number) => number): Int8Array; From 62f877a9838b25ecdbf8cce222d5a6e8d6a7c438 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 1 Nov 2022 18:02:02 -0500 Subject: [PATCH 04/18] Update esnext.typedarrays.d.ts --- src/lib/esnext.typedarrays.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/esnext.typedarrays.d.ts b/src/lib/esnext.typedarrays.d.ts index 0933e67e1ed2a..f1037c695f11e 100644 --- a/src/lib/esnext.typedarrays.d.ts +++ b/src/lib/esnext.typedarrays.d.ts @@ -81,7 +81,6 @@ interface Int8Array { * ```ts * const myNums = Int8Array.from([11, 2, -22, 1]); * myNums.toSorted((a, b) => a - b) // Int8Array(4) [-22, 1, 2, 11] - * ``` */ toSorted(compareFn?: (a: number, b: number) => number): Int8Array; From d4612e91b26e00eefdbb0f5cbfc6e02513d01c74 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Sun, 19 Feb 2023 16:56:19 -0600 Subject: [PATCH 05/18] fix errors and update for stage 4 release --- src/lib/es2023.array.d.ts | 652 ++++++++++++++++++++++++++++++-- src/lib/esnext.d.ts | 2 - src/lib/esnext.typedarrays.d.ts | 311 --------------- src/lib/lib.esnext.array.d.ts | 100 ----- 4 files changed, 613 insertions(+), 452 deletions(-) delete mode 100644 src/lib/esnext.typedarrays.d.ts delete mode 100644 src/lib/lib.esnext.array.d.ts diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index 1f90ae3396164..0c0b9ae36f36b 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -8,8 +8,14 @@ interface Array { * @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. */ - findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; + findLast( + predicate: (value: T, index: number, array: T[]) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: (value: T, index: number, array: T[]) => unknown, + thisArg?: any + ): T | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -20,7 +26,51 @@ interface Array { * @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. */ - findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; + findLastIndex( + predicate: (value: T, index: number, array: T[]) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copied array with all of its elements reversed. + */ + toReversed(): T[]; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Copies an array and removes elements while, if necessary, inserting new elements in their place, returning the remaining elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + * @returns A copy of the original array with the remaining elements. + */ + toSpliced(start: number, deleteCount: number, ...items: F[]): (T | F)[]; + + /** + * Copies an array and removes elements while returning the remaining elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @returns A copy of the original array with the remaining elements. + */ + toSpliced(start: number, deleteCount?: number): T[]; + + /** + * Copies the array and inserts the given value at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: F): (T | F)[]; } interface ReadonlyArray { @@ -33,8 +83,14 @@ interface ReadonlyArray { * @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. */ - findLast(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T | undefined; + findLast( + predicate: (value: T, index: number, array: readonly T[]) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: (value: T, index: number, array: readonly T[]) => unknown, + thisArg?: any + ): T | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -45,7 +101,51 @@ interface ReadonlyArray { * @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. */ - findLastIndex(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): number; + findLastIndex( + predicate: (value: T, index: number, array: readonly T[]) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copied array with all of its elements reversed. + */ + toReversed(): T[]; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: T, b: T) => number): T[]; + + /** + * Copies an array and removes elements while, if necessary, inserting new elements in their place, returning the remaining elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + * @returns A copy of the original array with the remaining elements. + */ + toSpliced(start: number, deleteCount: number, ...items: F[]): (T | F)[]; + + /** + * Copies an array and removes elements while returning the remaining elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @returns A copy of the original array with the remaining elements. + */ + toSpliced(start: number, deleteCount?: number): T[]; + + /** + * Copies the array and inserts the given value at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: F): (T | F)[]; } interface Int8Array { @@ -58,8 +158,18 @@ interface Int8Array { * @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. */ - findLast(predicate: (value: number, index: number, array: Int8Array) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any): number | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Int8Array + ) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: (value: number, index: number, array: Int8Array) => unknown, + thisArg?: any + ): number | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -70,7 +180,35 @@ interface Int8Array { * @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. */ - findLastIndex(predicate: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any): number; + findLastIndex( + predicate: (value: number, index: number, array: Int8Array) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Uint8Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Uint8Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint8Array; } interface Uint8Array { @@ -83,8 +221,18 @@ interface Uint8Array { * @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. */ - findLast(predicate: (value: number, index: number, array: Uint8Array) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): number | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Uint8Array + ) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: (value: number, index: number, array: Uint8Array) => unknown, + thisArg?: any + ): number | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -95,7 +243,35 @@ interface Uint8Array { * @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. */ - findLastIndex(predicate: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): number; + findLastIndex( + predicate: (value: number, index: number, array: Uint8Array) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Uint8Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Uint8Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint8Array; } interface Uint8ClampedArray { @@ -108,8 +284,22 @@ interface Uint8ClampedArray { * @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. */ - findLast(predicate: (value: number, index: number, array: Uint8ClampedArray) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): number | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Uint8ClampedArray + ) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Uint8ClampedArray + ) => unknown, + thisArg?: any + ): number | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -120,7 +310,39 @@ interface Uint8ClampedArray { * @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. */ - findLastIndex(predicate: (value: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): number; + findLastIndex( + predicate: ( + value: number, + index: number, + array: Uint8ClampedArray + ) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Uint8ClampedArray; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Uint8ClampedArray.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint8ClampedArray(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint8ClampedArray; } interface Int16Array { @@ -133,8 +355,18 @@ interface Int16Array { * @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. */ - findLast(predicate: (value: number, index: number, array: Int16Array) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any): number | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Int16Array + ) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: (value: number, index: number, array: Int16Array) => unknown, + thisArg?: any + ): number | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -145,7 +377,35 @@ interface Int16Array { * @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. */ - findLastIndex(predicate: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any): number; + findLastIndex( + predicate: (value: number, index: number, array: Int16Array) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Int16Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Int16Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int16Array(4) [-22, 1, 2, 11] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Int16Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Int16Array; } interface Uint16Array { @@ -158,8 +418,22 @@ interface Uint16Array { * @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. */ - findLast(predicate: (value: number, index: number, array: Uint16Array) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: Uint16Array) => unknown, thisArg?: any): number | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Uint16Array + ) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Uint16Array + ) => unknown, + thisArg?: any + ): number | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -170,7 +444,39 @@ interface Uint16Array { * @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. */ - findLastIndex(predicate: (value: number, index: number, array: Uint16Array) => unknown, thisArg?: any): number; + findLastIndex( + predicate: ( + value: number, + index: number, + array: Uint16Array + ) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Uint16Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Uint16Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint16Array(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint16Array; } interface Int32Array { @@ -183,8 +489,18 @@ interface Int32Array { * @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. */ - findLast(predicate: (value: number, index: number, array: Int32Array) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any): number | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Int32Array + ) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: (value: number, index: number, array: Int32Array) => unknown, + thisArg?: any + ): number | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -195,7 +511,35 @@ interface Int32Array { * @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. */ - findLastIndex(predicate: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any): number; + findLastIndex( + predicate: (value: number, index: number, array: Int32Array) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Int32Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Int32Array.from([11, 2, -22, 1]); + * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Int32Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Int32Array; } interface Uint32Array { @@ -208,8 +552,22 @@ interface Uint32Array { * @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. */ - findLast(predicate: (value: number, index: number, array: Uint32Array) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: Uint32Array) => unknown, thisArg?: any): number | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Uint32Array + ) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Uint32Array + ) => unknown, + thisArg?: any + ): number | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -220,7 +578,39 @@ interface Uint32Array { * @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. */ - findLastIndex(predicate: (value: number, index: number, array: Uint32Array) => unknown, thisArg?: any): number; + findLastIndex( + predicate: ( + value: number, + index: number, + array: Uint32Array + ) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Uint32Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Uint32Array.from([11, 2, 22, 1]); + * myNums.toSorted((a, b) => a - b) // Uint32Array(4) [1, 2, 11, 22] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Uint32Array; } interface Float32Array { @@ -233,8 +623,22 @@ interface Float32Array { * @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. */ - findLast(predicate: (value: number, index: number, array: Float32Array) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: Float32Array) => unknown, thisArg?: any): number | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Float32Array + ) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Float32Array + ) => unknown, + thisArg?: any + ): number | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -245,7 +649,39 @@ interface Float32Array { * @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. */ - findLastIndex(predicate: (value: number, index: number, array: Float32Array) => unknown, thisArg?: any): number; + findLastIndex( + predicate: ( + value: number, + index: number, + array: Float32Array + ) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Float32Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Float32Array.from([11.25, 2, -22.5, 1]); + * myNums.toSorted((a, b) => a - b) // Float32Array(4) [-22.5, 1, 2, 11.5] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Float32Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Float32Array; } interface Float64Array { @@ -258,8 +694,22 @@ interface Float64Array { * @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. */ - findLast(predicate: (value: number, index: number, array: Float64Array) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: number, index: number, array: Float64Array) => unknown, thisArg?: any): number | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Float64Array + ) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: ( + value: number, + index: number, + array: Float64Array + ) => unknown, + thisArg?: any + ): number | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -270,7 +720,39 @@ interface Float64Array { * @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. */ - findLastIndex(predicate: (value: number, index: number, array: Float64Array) => unknown, thisArg?: any): number; + findLastIndex( + predicate: ( + value: number, + index: number, + array: Float64Array + ) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): Float64Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = Float64Array.from([11.25, 2, -22.5, 1]); + * myNums.toSorted((a, b) => a - b) // Float64Array(4) [-22.5, 1, 2, 11.5] + * ``` + */ + toSorted(compareFn?: (a: number, b: number) => number): Float64Array; + + /** + * Copies the array and inserts the given number at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: number): Float64Array; } interface BigInt64Array { @@ -283,8 +765,22 @@ interface BigInt64Array { * @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. */ - findLast(predicate: (value: bigint, index: number, array: BigInt64Array) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: bigint, index: number, array: BigInt64Array) => unknown, thisArg?: any): bigint | undefined; + findLast( + predicate: ( + value: bigint, + index: number, + array: BigInt64Array + ) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: ( + value: bigint, + index: number, + array: BigInt64Array + ) => unknown, + thisArg?: any + ): bigint | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -295,7 +791,39 @@ interface BigInt64Array { * @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. */ - findLastIndex(predicate: (value: bigint, index: number, array: BigInt64Array) => unknown, thisArg?: any): number; + findLastIndex( + predicate: ( + value: bigint, + index: number, + array: BigInt64Array + ) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): BigInt64Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = BigInt64Array.from([11n, 2n, -22n, 1n]); + * myNums.toSorted((a, b) => Number(a - b)) // BigInt64Array(4) [-22n, 1n, 2n, 11n] + * ``` + */ + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; + + /** + * Copies the array and inserts the given bigint at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: bigint): BigInt64Array; } interface BigUint64Array { @@ -308,8 +836,22 @@ interface BigUint64Array { * @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. */ - findLast(predicate: (value: bigint, index: number, array: BigUint64Array) => value is S, thisArg?: any): S | undefined; - findLast(predicate: (value: bigint, index: number, array: BigUint64Array) => unknown, thisArg?: any): bigint | undefined; + findLast( + predicate: ( + value: bigint, + index: number, + array: BigUint64Array + ) => value is S, + thisArg?: any + ): S | undefined; + findLast( + predicate: ( + value: bigint, + index: number, + array: BigUint64Array + ) => unknown, + thisArg?: any + ): bigint | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -320,5 +862,37 @@ interface BigUint64Array { * @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. */ - findLastIndex(predicate: (value: bigint, index: number, array: BigUint64Array) => unknown, thisArg?: any): number; + findLastIndex( + predicate: ( + value: bigint, + index: number, + array: BigUint64Array + ) => unknown, + thisArg?: any + ): number; + + /** + * Copies the array and returns the copy with the elements in reverse order. + */ + toReversed(): BigUint64Array; + + /** + * Copies and sorts the array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * const myNums = BigUint64Array.from([11n, 2n, 22n, 1n]); + * myNums.toSorted((a, b) => Number(a - b)) // BigUint64Array(4) [1n, 2n, 11n, 22n] + * ``` + */ + toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; + + /** + * Copies the array and inserts the given bigint at the provided index. + * @param index The index to insert the value at. + * @param value The value to insert into the copied array. + * @returns A copy of the original array with the inserted value. + */ + with(index: number, value: bigint): BigUint64Array; } diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index 97b3590e13e57..30eaf070bfb96 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -1,4 +1,2 @@ /// /// -/// -/// diff --git a/src/lib/esnext.typedarrays.d.ts b/src/lib/esnext.typedarrays.d.ts deleted file mode 100644 index f1037c695f11e..0000000000000 --- a/src/lib/esnext.typedarrays.d.ts +++ /dev/null @@ -1,311 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -interface Uint8Array { - /** - * Copies the array and returns the copy with the elements in reverse order. - */ - toReversed(): Uint8Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * const myNums = Uint8Array.from([11, 2, 22, 1]); - * myNums.toSorted((a, b) => a - b) // Uint8Array(4) [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Uint8Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Uint8Array; -} - -interface Uint8ClampedArray { - /** - * Copies the array and returns the copy with the elements in reverse order. - */ - toReversed(): Uint8ClampedArray; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * const myNums = Uint8ClampedArray.from([11, 2, 22, 1]); - * myNums.toSorted((a, b) => a - b) // Uint8ClampedArray(4) [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Uint8ClampedArray; -} - -interface Int8Array { - /** - * Copies the array and returns the copy with the elements in reverse order. - */ - toReversed(): Int8Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * const myNums = Int8Array.from([11, 2, -22, 1]); - * myNums.toSorted((a, b) => a - b) // Int8Array(4) [-22, 1, 2, 11] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Int8Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Int8Array; -} - -interface Uint16Array { - /** - * Copies the array and returns the copy with the elements in reverse order. - */ - toReversed(): Uint16Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * const myNums = Uint16Array.from([11, 2, 22, 1]); - * myNums.toSorted((a, b) => a - b) // Uint16Array(4) [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Uint16Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Uint16Array; -} - -interface Int16Array { - /** - * Copies the array and returns the copy with the elements in reverse order. - */ - toReversed(): Int16Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * const myNums = Int16Array.from([11, 2, -22, 1]); - * myNums.toSorted((a, b) => a - b) // Int16Array(4) [-22, 1, 2, 11] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Int16Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Int16Array; -} - -interface Uint32Array { - /** - * Copies the array and returns the copy with the elements in reverse order. - */ - toReversed(): Uint32Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * const myNums = Uint32Array.from([11, 2, 22, 1]); - * myNums.toSorted((a, b) => a - b) // Uint32Array(4) [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Uint32Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Uint32Array; -} - -interface Int32Array { - /** - * Copies the array and returns the copy with the elements in reverse order. - */ - toReversed(): Int32Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * const myNums = Int32Array.from([11, 2, -22, 1]); - * myNums.toSorted((a, b) => a - b) // Int32Array(4) [-22, 1, 2, 11] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Int32Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Int32Array; -} - -interface Float32Array { - /** - * Copies the array and returns the copy with the elements in reverse order. - */ - toReversed(): Float32Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * const myNums = Float32Array.from([11.25, 2, -22.5, 1]); - * myNums.toSorted((a, b) => a - b) // Float32Array(4) [-22.5, 1, 2, 11.5] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Float32Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Float32Array; -} - -interface Float64Array { - /** - * Copies the array and returns the copy with the elements in reverse order. - */ - toReversed(): Float64Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * const myNums = Float64Array.from([11.25, 2, -22.5, 1]); - * myNums.toSorted((a, b) => a - b) // Float64Array(4) [-22.5, 1, 2, 11.5] - * ``` - */ - toSorted(compareFn?: (a: number, b: number) => number): Float64Array; - - /** - * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: number): Float64Array; -} - -interface BigUint64Array { - /** - * Copies the array and returns the copy with the elements in reverse order. - */ - toReversed(): BigUint64Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * const myNums = BigUint64Array.from([11n, 2n, 22n, 1n]); - * myNums.toSorted((a, b) => Number(a - b)) // BigUint64Array(4) [1n, 2n, 11n, 22n] - * ``` - */ - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigUint64Array; - - /** - * Copies the array and inserts the given bigint at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: bigint): BigUint64Array; -} - -interface BigInt64Array { - /** - * Copies the array and returns the copy with the elements in reverse order. - */ - toReversed(): BigInt64Array; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * const myNums = BigInt64Array.from([11n, 2n, -22n, 1n]); - * myNums.toSorted((a, b) => Number(a - b)) // BigInt64Array(4) [-22n, 1n, 2n, 11n] - * ``` - */ - toSorted(compareFn?: (a: bigint, b: bigint) => number): BigInt64Array; - - /** - * Copies the array and inserts the given bigint at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: bigint): BigInt64Array; -} diff --git a/src/lib/lib.esnext.array.d.ts b/src/lib/lib.esnext.array.d.ts deleted file mode 100644 index 766c228fec12b..0000000000000 --- a/src/lib/lib.esnext.array.d.ts +++ /dev/null @@ -1,100 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -interface Array { - /** - * Copies the array and returns the copied array with all of its elements reversed. - */ - toReversed(): T[]; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: T, b: T) => number): T[]; - - /** - * Copies an array and removes elements while, if necessary, inserting new elements in their place, returning the remaining elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - * @returns A copy of the original array with the remaining elements. - */ - toSpliced(start: number, deleteCount: number, ...items: F[]): (T | F)[]; - - /** - * Copies an array and removes elements while returning the remaining elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @returns A copy of the original array with the remaining elements. - */ - toSpliced(start: number, deleteCount?: number): T[]; - - /** - * Copies the array and inserts the given value at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: F): (T | F)[]; -} - -interface ReadonlyArray { - /** - * Copies the array and returns the copied array with all of its elements reversed. - */ - toReversed(): T[]; - - /** - * Copies and sorts the array. - * @param compareFn Function used to determine the order of the elements. It is expected to return - * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. - * ```ts - * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] - * ``` - */ - toSorted(compareFn?: (a: T, b: T) => number): T[]; - - /** - * Copies an array and removes elements while, if necessary, inserting new elements in their place, returning the remaining elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - * @returns A copy of the original array with the remaining elements. - */ - toSpliced(start: number, deleteCount: number, ...items: F[]): (T | F)[]; - - /** - * Copies an array and removes elements while returning the remaining elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @returns A copy of the original array with the remaining elements. - */ - toSpliced(start: number, deleteCount?: number): T[]; - - /** - * Copies the array and inserts the given value at the provided index. - * @param index The index to insert the value at. - * @param value The value to insert into the copied array. - * @returns A copy of the original array with the inserted value. - */ - with(index: number, value: F): (T | F)[]; -} From edef0f3a518aa79abe5973548bbc0fa28428fe84 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 14 Mar 2023 17:04:42 -0500 Subject: [PATCH 06/18] Update src/lib/es2023.array.d.ts Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> --- src/lib/es2023.array.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index 0c0b9ae36f36b..ad830a54a1e88 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -32,7 +32,7 @@ interface Array { ): number; /** - * Copies the array and returns the copied array with all of its elements reversed. + * Returns a copy of an array with its elements reversed. */ toReversed(): T[]; From 4f39fec7daa016290abd245bf005e37edacaf23f Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 14 Mar 2023 17:04:56 -0500 Subject: [PATCH 07/18] Update src/lib/es2023.array.d.ts Co-authored-by: Tim Buckley --- src/lib/es2023.array.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index ad830a54a1e88..a35035bf84ac2 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -37,7 +37,7 @@ interface Array { toReversed(): T[]; /** - * Copies and sorts the array. + * Returns a copy of an array with its elements sorted. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. From 5f46ee14a7205a09af9d6b2bcbbb7e5824459519 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 14 Mar 2023 17:05:52 -0500 Subject: [PATCH 08/18] Update src/lib/es2023.array.d.ts Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> --- src/lib/es2023.array.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index a35035bf84ac2..250e8b255615d 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -48,7 +48,7 @@ interface Array { toSorted(compareFn?: (a: T, b: T) => number): T[]; /** - * Copies an array and removes elements while, if necessary, inserting new elements in their place, returning the remaining elements. + * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. * @param start The zero-based location in the array from which to start removing elements. * @param deleteCount The number of elements to remove. * @param items Elements to insert into the array in place of the deleted elements. From d223a099cf7f3bd1e8aba92d1b554196736cc9d9 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 14 Mar 2023 17:06:07 -0500 Subject: [PATCH 09/18] Update src/lib/es2023.array.d.ts Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> --- src/lib/es2023.array.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index 250e8b255615d..065fcdbfa2db1 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -65,7 +65,7 @@ interface Array { toSpliced(start: number, deleteCount?: number): T[]; /** - * Copies the array and inserts the given value at the provided index. + * Copies an array, then overwrites the value at the provided index with the given value. * @param index The index to insert the value at. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. From f7272183374565aa85b46ee7c378e19f92e2af16 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 14 Mar 2023 17:06:44 -0500 Subject: [PATCH 10/18] Update src/lib/es2023.array.d.ts Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> --- src/lib/es2023.array.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index 065fcdbfa2db1..f8543c556ce5f 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -67,7 +67,7 @@ interface Array { /** * Copies an array, then overwrites the value at the provided index with the given value. * @param index The index to insert the value at. - * @param value The value to insert into the copied array. + * @param value The value to write into the copied array. * @returns A copy of the original array with the inserted value. */ with(index: number, value: F): (T | F)[]; From fd3f8425949055841eea94ed7815831eb50cf4b2 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 14 Mar 2023 17:06:54 -0500 Subject: [PATCH 11/18] Update src/lib/es2023.array.d.ts Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> --- src/lib/es2023.array.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index f8543c556ce5f..7985d8433ee70 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -68,7 +68,8 @@ interface Array { * Copies an array, then overwrites the value at the provided index with the given value. * @param index The index to insert the value at. * @param value The value to write into the copied array. - * @returns A copy of the original array with the inserted value. + * @returns The copied array with the updated value. + */ with(index: number, value: F): (T | F)[]; } From 3b4ff854f1267950ddd396f2b985a90656204363 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 14 Mar 2023 17:07:18 -0500 Subject: [PATCH 12/18] Update src/lib/es2023.array.d.ts Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> --- src/lib/es2023.array.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index 7985d8433ee70..d47fd2f0713f9 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -52,7 +52,7 @@ interface Array { * @param start The zero-based location in the array from which to start removing elements. * @param deleteCount The number of elements to remove. * @param items Elements to insert into the array in place of the deleted elements. - * @returns A copy of the original array with the remaining elements. + * @returns The copied array. */ toSpliced(start: number, deleteCount: number, ...items: F[]): (T | F)[]; From 00fddd971ec75b5c97420e57a682b146d09c2ee9 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 14 Mar 2023 17:10:29 -0500 Subject: [PATCH 13/18] x --- src/lib/es2023.array.d.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index d47fd2f0713f9..2cd90cdbd43ee 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -66,7 +66,7 @@ interface Array { /** * Copies an array, then overwrites the value at the provided index with the given value. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to write into the copied array. * @returns The copied array with the updated value. @@ -142,7 +142,7 @@ interface ReadonlyArray { /** * Copies the array and inserts the given value at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -205,7 +205,7 @@ interface Int8Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -268,7 +268,7 @@ interface Uint8Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -339,7 +339,7 @@ interface Uint8ClampedArray { /** * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -402,7 +402,7 @@ interface Int16Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -473,7 +473,7 @@ interface Uint16Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -536,7 +536,7 @@ interface Int32Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -607,7 +607,7 @@ interface Uint32Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -678,7 +678,7 @@ interface Float32Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -749,7 +749,7 @@ interface Float64Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -820,7 +820,7 @@ interface BigInt64Array { /** * Copies the array and inserts the given bigint at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -891,7 +891,7 @@ interface BigUint64Array { /** * Copies the array and inserts the given bigint at the provided index. - * @param index The index to insert the value at. + * @param index The index of the value to overwrite. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ From d20325d1bf3adeee78207bacb741d804377f9374 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Tue, 14 Mar 2023 17:11:56 -0500 Subject: [PATCH 14/18] undo formatting --- src/lib/es2023.array.d.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index 2cd90cdbd43ee..45823629c8575 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -8,14 +8,8 @@ interface Array { * @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. */ - findLast( - predicate: (value: T, index: number, array: T[]) => value is S, - thisArg?: any - ): S | undefined; - findLast( - predicate: (value: T, index: number, array: T[]) => unknown, - thisArg?: any - ): T | undefined; + findLast(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S | undefined; + findLast(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the last element in the array where predicate is true, and -1 @@ -26,10 +20,7 @@ interface Array { * @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. */ - findLastIndex( - predicate: (value: T, index: number, array: T[]) => unknown, - thisArg?: any - ): number; + findLastIndex(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): number; /** * Returns a copy of an array with its elements reversed. From 635579c549c6f0af14a91901bb56cdd499c82b67 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Sun, 9 Apr 2023 08:37:36 -0500 Subject: [PATCH 15/18] address concerns --- src/lib/es2023.array.d.ts | 56 +++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index 45823629c8575..0edab6c1a61a4 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -45,7 +45,7 @@ interface Array { * @param items Elements to insert into the array in place of the deleted elements. * @returns The copied array. */ - toSpliced(start: number, deleteCount: number, ...items: F[]): (T | F)[]; + toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; /** * Copies an array and removes elements while returning the remaining elements. @@ -56,13 +56,15 @@ interface Array { toSpliced(start: number, deleteCount?: number): T[]; /** - * Copies an array, then overwrites the value at the provided index with the given value. - * @param index The index of the value to overwrite. + * Copies an array, then overwrites the value at the provided index with the + * given value. If the index is negative, then it replaces from the start + * of the array. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to write into the copied array. * @returns The copied array with the updated value. - */ - with(index: number, value: F): (T | F)[]; + with(index: number, value: T): T[]; } interface ReadonlyArray { @@ -121,7 +123,7 @@ interface ReadonlyArray { * @param items Elements to insert into the array in place of the deleted elements. * @returns A copy of the original array with the remaining elements. */ - toSpliced(start: number, deleteCount: number, ...items: F[]): (T | F)[]; + toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; /** * Copies an array and removes elements while returning the remaining elements. @@ -132,12 +134,15 @@ interface ReadonlyArray { toSpliced(start: number, deleteCount?: number): T[]; /** - * Copies the array and inserts the given value at the provided index. - * @param index The index of the value to overwrite. + * Copies an array, then overwrites the value at the provided index with the + * given value. If the index is negative, then it replaces from the start + * of the array + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ - with(index: number, value: F): (T | F)[]; + with(index: number, value: T): T[]; } interface Int8Array { @@ -196,7 +201,8 @@ interface Int8Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -259,7 +265,8 @@ interface Uint8Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -330,7 +337,8 @@ interface Uint8ClampedArray { /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -393,7 +401,8 @@ interface Int16Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -464,7 +473,8 @@ interface Uint16Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -527,7 +537,8 @@ interface Int32Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -598,7 +609,8 @@ interface Uint32Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -669,7 +681,8 @@ interface Float32Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -740,7 +753,8 @@ interface Float64Array { /** * Copies the array and inserts the given number at the provided index. - * @param index The index of the value to overwrite. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -811,7 +825,8 @@ interface BigInt64Array { /** * Copies the array and inserts the given bigint at the provided index. - * @param index The index of the value to overwrite. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ @@ -882,7 +897,8 @@ interface BigUint64Array { /** * Copies the array and inserts the given bigint at the provided index. - * @param index The index of the value to overwrite. + * @param index The index of the value to overwrite. If the index is + * negative, then it replaces from the end of the array. * @param value The value to insert into the copied array. * @returns A copy of the original array with the inserted value. */ From 618bef066e91daea6940f9c5f46c6f36bfd71b56 Mon Sep 17 00:00:00 2001 From: Carter Snook Date: Sun, 9 Apr 2023 08:39:26 -0500 Subject: [PATCH 16/18] use "copied array" phrasing for `toSpliced` --- src/lib/es2023.array.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index 0edab6c1a61a4..65cda4bc728a2 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -42,7 +42,7 @@ interface Array { * Copies an array and removes elements and, if necessary, inserts new elements in their place. Returns the copied array. * @param start The zero-based location in the array from which to start removing elements. * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. + * @param items Elements to insert into the copied array in place of the deleted elements. * @returns The copied array. */ toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; @@ -120,7 +120,7 @@ interface ReadonlyArray { * Copies an array and removes elements while, if necessary, inserting new elements in their place, returning the remaining elements. * @param start The zero-based location in the array from which to start removing elements. * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. + * @param items Elements to insert into the copied array in place of the deleted elements. * @returns A copy of the original array with the remaining elements. */ toSpliced(start: number, deleteCount: number, ...items: T[]): T[]; From af202f2b49c543157842d6677af158561e757b80 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 2 Jun 2023 09:18:29 -0700 Subject: [PATCH 17/18] Update src/lib/es2023.array.d.ts Co-authored-by: Albert Arvidsson --- src/lib/es2023.array.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index 65cda4bc728a2..d6c5de957e49b 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -135,7 +135,7 @@ interface ReadonlyArray { /** * Copies an array, then overwrites the value at the provided index with the - * given value. If the index is negative, then it replaces from the start + * given value. If the index is negative, then it replaces from the end * of the array * @param index The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array. From a8219f98c34ba931375a879f88cdca4ca5bc41ec Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 2 Jun 2023 09:22:57 -0700 Subject: [PATCH 18/18] change another start->end for negative indices --- src/lib/es2023.array.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index d6c5de957e49b..a5cc73ae0f963 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -57,7 +57,7 @@ interface Array { /** * Copies an array, then overwrites the value at the provided index with the - * given value. If the index is negative, then it replaces from the start + * given value. If the index is negative, then it replaces from the end * of the array. * @param index The index of the value to overwrite. If the index is * negative, then it replaces from the end of the array.