Skip to content

Commit

Permalink
Fix JSDoc for Array#sort, TypedArray#sort and Array#toSorted methods (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
BitFlippa27 authored Jan 16, 2025
1 parent 700ee07 commit 7901a39
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/lib/es2023.array.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface Array<T> {
* 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.
* value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order.
* ```ts
* [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22]
* ```
Expand Down Expand Up @@ -109,7 +109,7 @@ interface ReadonlyArray<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.
* value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order.
* ```ts
* [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22]
* ```
Expand Down
2 changes: 1 addition & 1 deletion src/lib/es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ interface Array<T> {
* This method mutates the array and returns a reference to the same 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.
* value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order.
* ```ts
* [11,2,22,1].sort((a, b) => a - b)
* ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4190,7 +4190,7 @@
"kind": "space"
},
{
"text": "Function used to determine the order of the elements. It is expected to return\na negative value if the first argument is less than the second argument, zero if they're equal, and a positive\nvalue otherwise. If omitted, the elements are sorted in ascending, ASCII character order.\n```ts\n[11,2,22,1].sort((a, b) => a - b)\n```",
"text": "Function used to determine the order of the elements. It is expected to return\na negative value if the first argument is less than the second argument, zero if they're equal, and a positive\nvalue otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order.\n```ts\n[11,2,22,1].sort((a, b) => a - b)\n```",
"kind": "text"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
// * This method mutates the array and returns a reference to the same 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.
// * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order.
// * ```ts
// * [11,2,22,1].sort((a, b) => a - b)
// * ```
Expand Down Expand Up @@ -331,7 +331,7 @@
// * This method mutates the array and returns a reference to the same 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.
// * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order.
// * ```ts
// * [11,2,22,1].sort((a, b) => a - b)
// * ```
Expand Down
20 changes: 10 additions & 10 deletions tests/lib/lib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ interface Array<T> {

/**
* Sorts an array.
* @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order.
* @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, UTF-16 code unit order.
*/
sort(compareFn?: (a: T, b: T) => number): T[];

Expand Down Expand Up @@ -1612,7 +1612,7 @@ interface Int8Array {
/**
* Sorts an array.
* @param compareFn The name of the function used to determine the order of the elements. If
* omitted, the elements are sorted in ascending, ASCII character order.
* omitted, the elements are sorted in ascending, numerical order.
*/
sort(compareFn?: (a: number, b: number) => number): Int8Array;

Expand Down Expand Up @@ -1885,7 +1885,7 @@ interface Uint8Array {
/**
* Sorts an array.
* @param compareFn The name of the function used to determine the order of the elements. If
* omitted, the elements are sorted in ascending, ASCII character order.
* omitted, the elements are sorted in ascending, numerical order.
*/
sort(compareFn?: (a: number, b: number) => number): Uint8Array;

Expand Down Expand Up @@ -2159,7 +2159,7 @@ interface Uint8ClampedArray {
/**
* Sorts an array.
* @param compareFn The name of the function used to determine the order of the elements. If
* omitted, the elements are sorted in ascending, ASCII character order.
* omitted, the elements are sorted in ascending, numerical order.
*/
sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray;

Expand Down Expand Up @@ -2432,7 +2432,7 @@ interface Int16Array {
/**
* Sorts an array.
* @param compareFn The name of the function used to determine the order of the elements. If
* omitted, the elements are sorted in ascending, ASCII character order.
* omitted, the elements are sorted in ascending, numerical order.
*/
sort(compareFn?: (a: number, b: number) => number): Int16Array;

Expand Down Expand Up @@ -2706,7 +2706,7 @@ interface Uint16Array {
/**
* Sorts an array.
* @param compareFn The name of the function used to determine the order of the elements. If
* omitted, the elements are sorted in ascending, ASCII character order.
* omitted, the elements are sorted in ascending, numerical order.
*/
sort(compareFn?: (a: number, b: number) => number): Uint16Array;

Expand Down Expand Up @@ -2979,7 +2979,7 @@ interface Int32Array {
/**
* Sorts an array.
* @param compareFn The name of the function used to determine the order of the elements. If
* omitted, the elements are sorted in ascending, ASCII character order.
* omitted, the elements are sorted in ascending, numerical order.
*/
sort(compareFn?: (a: number, b: number) => number): Int32Array;

Expand Down Expand Up @@ -3252,7 +3252,7 @@ interface Uint32Array {
/**
* Sorts an array.
* @param compareFn The name of the function used to determine the order of the elements. If
* omitted, the elements are sorted in ascending, ASCII character order.
* omitted, the elements are sorted in ascending, numerical order.
*/
sort(compareFn?: (a: number, b: number) => number): Uint32Array;

Expand Down Expand Up @@ -3525,7 +3525,7 @@ interface Float32Array {
/**
* Sorts an array.
* @param compareFn The name of the function used to determine the order of the elements. If
* omitted, the elements are sorted in ascending, ASCII character order.
* omitted, the elements are sorted in ascending, numerical order.
*/
sort(compareFn?: (a: number, b: number) => number): Float32Array;

Expand Down Expand Up @@ -3799,7 +3799,7 @@ interface Float64Array {
/**
* Sorts an array.
* @param compareFn The name of the function used to determine the order of the elements. If
* omitted, the elements are sorted in ascending, ASCII character order.
* omitted, the elements are sorted in ascending, numerical order.
*/
sort(compareFn?: (a: number, b: number) => number): Float64Array;

Expand Down

0 comments on commit 7901a39

Please sign in to comment.