Skip to content

Commit f3d3968

Browse files
authored
lib: fix misleading maxLength param on string pad* methods (#63504)
1 parent e5509e2 commit f3d3968

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

src/lib/es2017.string.d.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
interface String {
22
/**
3-
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
4-
* The padding is applied from the start (left) of the current string.
3+
* Pads the current string with a given string (repeated and/or truncated, if needed) so that the resulting string has a given length.
4+
* The padding is applied from the start of the current string.
55
*
6-
* @param maxLength The length of the resulting string once the current string has been padded.
7-
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
6+
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart)
87
*
9-
* @param fillString The string to pad the current string with.
10-
* If this string is too long, it will be truncated and the left-most part will be applied.
11-
* The default value for this parameter is " " (U+0020).
8+
* @param targetLength The length of the resulting string once the current `str` has been padded.
9+
* If the value is less than or equal to `str.length`, then `str` is returned as-is.
10+
*
11+
* @param padString The string to pad the current `str` with.
12+
* If `padString` is too long to stay within `targetLength`, it will be truncated from the end.
13+
* The default value is the space character (U+0020).
1214
*/
13-
padStart(maxLength: number, fillString?: string): string;
15+
padStart(targetLength: number, padString?: string): string;
1416

1517
/**
16-
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
17-
* The padding is applied from the end (right) of the current string.
18+
* Pads the current string with a given string (repeated and/or truncated, if needed) so that the resulting string has a given length.
19+
* The padding is applied from the end of the current string.
20+
*
21+
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd)
1822
*
19-
* @param maxLength The length of the resulting string once the current string has been padded.
20-
* If this parameter is smaller than the current string's length, the current string will be returned as it is.
23+
* @param targetLength The length of the resulting string once the current `str` has been padded.
24+
* If the value is less than or equal to `str.length`, then `str` is returned as-is.
2125
*
22-
* @param fillString The string to pad the current string with.
23-
* If this string is too long, it will be truncated and the left-most part will be applied.
24-
* The default value for this parameter is " " (U+0020).
26+
* @param padString The string to pad the current `str` with.
27+
* If `padString` is too long to stay within `targetLength`, it will be truncated from the end.
28+
* The default value is the space character (U+0020).
2529
*/
26-
padEnd(maxLength: number, fillString?: string): string;
30+
padEnd(targetLength: number, padString?: string): string;
2731
}

0 commit comments

Comments
 (0)