MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / truncateString

Function truncateString

lib/utils.js:679–690  ·  view source on GitHub ↗
(str, maxBytes)

Source from the content-addressed store, hash-verified

677 * @returns {{ value: string, truncated: boolean, fullLength: number }}
678 */
679export const truncateString = function (str, maxBytes) {
680 if (typeof str !== 'string') str = String(str)
681 if (str.length <= maxBytes) {
682 return { value: str, truncated: false, fullLength: str.length }
683 }
684 const dropped = str.length - maxBytes
685 return {
686 value: `${str.slice(0, maxBytes)}\n...[truncated ${dropped} more chars]`,
687 truncated: true,
688 fullLength: str.length,
689 }
690}
691
692export const serializeError = function (error) {
693 if (error) {

Callers 3

captureLogFunction · 0.90
mcp-server.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected