Function
truncateText
(
text: string,
maxChars: number,
)
Source from the content-addressed store, hash-verified
| 307 | } |
| 308 | |
| 309 | function truncateText( |
| 310 | text: string, |
| 311 | maxChars: number, |
| 312 | ): { |
| 313 | text: string |
| 314 | truncated: boolean |
| 315 | } { |
| 316 | if (text.length <= maxChars) { |
| 317 | return { text, truncated: false } |
| 318 | } |
| 319 | return { |
| 320 | text: `${text.slice(0, maxChars).trimEnd()}\n\n[Content truncated]`, |
| 321 | truncated: true, |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | export async function readUrl({ |
| 326 | url, |
Tested by
no test coverage detected