Skip to main content

truncateUtf8

@webda/mcp


Function: truncateUtf8()

truncateUtf8(text, maxBytes): object

Defined in: packages/mcp/src/invoke.ts:138

Truncate a string to at most maxBytes UTF-8 bytes without cutting a character

Parameters​

text​

string

the text

maxBytes​

number

maximum number of bytes kept

Returns​

object

the (possibly) truncated text, whether it was truncated and the original byte length

bytes​

bytes: number

text​

text: string

truncated​

truncated: boolean