Skip to content

Commit 1fe0c8a

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

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/string.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ 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+
* @example
48+
* truncateMiddle('Hello, world!', 5, 6); // 'Hello&hellip;world!'
49+
* truncateMiddle('Hello, world!', 5, 0); // 'Hello&hellip;'
50+
* truncateMiddle('Hello, world!', 0, 6); // '&hellip;world!'
51+
* truncateMiddle('Hello, world!', 0, 0); // 'Hello, world!'
52+
*
4753
* @license https://github.com/kahwee/truncate-middle#license
4854
* @param str - String to be truncated
4955
* @param frontLen - Number of characters to be remained in front

0 commit comments

Comments
 (0)