truncate
truncate(
params):string
Defined in: strings/truncate/index.ts:23
Truncates a string to a specified length with an optional suffix.
Parameters
Section titled “Parameters”params
Section titled “params”TruncateParams
The parameters object
Returns
Section titled “Returns”string
The truncated string, or the original if shorter than length
Example
Section titled “Example”truncate({ str: "Hello, World!", length: 5 });// => "Hello..."Keywords
Section titled “Keywords”shorten text, ellipsis, cut string, text overflow
Throws
Section titled “Throws”Error if str is not a string
Throws
Section titled “Throws”Error if length is not a positive integer