Skip to content

Commit e876128

Browse files
committed
docs(string): add truncateMiddle examples
1 parent 3e6dff2 commit e876128

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/string.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ export function initials(name: Maybe<string>): Optional<string> {
4444
* There are cases where important information is at the end of the string and truncating the end isn't helpful.
4545
* This function solves that.
4646
*
47-
* @license https://github.com/kahwee/truncate-middle#license
48-
* @param str - String to be truncated
49-
* @param frontLen - Number of characters to be remained in front
50-
* @param backLen - Number of characters to be remained at the back
51-
* @param truncateStr - String that replaces the truncated portion
52-
* @returns Truncated string. Defaults to '&hellip;' if unspecified
47+
* ```ts
48+
* truncateMiddle('very-long-file-name.txt', 10, 4); // 'very-long&hellip;name.txt'
49+
* truncateMiddle('Hello, world!', 5, 6); // 'Hello&hellip;world!'
50+
* truncateMiddle('Hello, world!', 5, 0); // 'Hello&hellip;'
51+
* truncateMiddle('Hello, world!', 0, 6); // '&hellip;world!'
52+
* truncateMiddle('Hello, world!', 0, 0); // 'Hello, world!'
53+
* ```
5354
*/
5455
export function truncateMiddle(
5556
str: Maybe<string>,

0 commit comments

Comments
 (0)