codetrix
Version:
A lightweight lodash-style utility library
13 lines (12 loc) • 409 B
TypeScript
/**
* Truncates a string to a specified length, adding a suffix if needed.
*
* @param str - The string to truncate.
* @param length - The maximum allowed length.
* @param suffix - The suffix to add (default is '...').
* @returns The truncated string.
*
* @example
* truncate('Hello World', 5); // 'Hello...'
*/
export declare function truncate(str: string, length: number, suffix?: string): string;