Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Latest commit

 

History

History
28 lines (19 loc) · 476 Bytes

trim_string.md

File metadata and controls

28 lines (19 loc) · 476 Bytes

strings/trimString

Trim a string to a certain length with an ellipsis

function trimString(str: string, maxLength: number)

Args

str:string
The string to trim.

maxLength:number
The maximum number of characters.

Returns

The trimmed string.

Examples

import { trimString } from '@deskpro/js-utils/dist/strings';

console.log(trimString('abcdefg', 6)); // Outputs abc...
console.log(trimString('abcde', 6)); // Outputs abcde