(
text: string,
options?: { ellipsis?: string },
)
| 130 | } |
| 131 | |
| 132 | export function truncateMultilineText( |
| 133 | text: string, |
| 134 | options?: { ellipsis?: string }, |
| 135 | ): string { |
| 136 | const { ellipsis = `[${UNICODE_ELLIPSIS}]` } = options ?? {}; |
| 137 | |
| 138 | const crlfIndex = text.indexOf('\r\n'); |
| 139 | const lfIndex = text.indexOf('\n'); |
| 140 | const index = crlfIndex === -1 ? lfIndex : crlfIndex; |
| 141 | |
| 142 | if (index < 0) { |
| 143 | return text; |
| 144 | } |
| 145 | |
| 146 | const firstLine = text.slice(0, index); |
| 147 | if (text.slice(index).trim().length === 0) { |
| 148 | return firstLine; |
| 149 | } |
| 150 | return `${firstLine} ${ellipsis}`; |
| 151 | } |
| 152 | |
| 153 | export function transformLines( |
| 154 | text: string, |
no outgoing calls
no test coverage detected