(str, maxBytes)
| 677 | * @returns {{ value: string, truncated: boolean, fullLength: number }} |
| 678 | */ |
| 679 | export 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 | |
| 692 | export const serializeError = function (error) { |
| 693 | if (error) { |
no outgoing calls
no test coverage detected