|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
966 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Pads the start of a string with a given character until it reaches the specified length.
|
|---|
| 3 | *
|
|---|
| 4 | * If the length is less than or equal to the original string's length, or if the padding character is an empty string,
|
|---|
| 5 | * the original string is returned unchanged.
|
|---|
| 6 | *
|
|---|
| 7 | * @param {string} str - The string to pad.
|
|---|
| 8 | * @param {number} [length] - The length of the resulting string once padded.
|
|---|
| 9 | * @param {string} [chars] - The character(s) to use for padding.
|
|---|
| 10 | * @returns {string} - The padded string, or the original string if padding is not required.
|
|---|
| 11 | *
|
|---|
| 12 | * @example
|
|---|
| 13 | * const result1 = padStart('abc', 6); // result will be ' abc'
|
|---|
| 14 | * const result2 = padStart('abc', 6, '_-'); // result will be '_-_abc'
|
|---|
| 15 | * const result3 = padStart('abc', 3); // result will be 'abc'
|
|---|
| 16 | * const result4 = padStart('abc', 2); // result will be 'abc'
|
|---|
| 17 | */
|
|---|
| 18 | declare function padStart(str?: string, length?: number, chars?: string): string;
|
|---|
| 19 |
|
|---|
| 20 | export { padStart };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.