Skip to main content

boundExcerpt

@forge/monorepo


@forge/monorepo / backend/src / boundExcerpt

Function: boundExcerpt()

boundExcerpt(text, max?): string

Defined in: backend/src/citations/index.ts:44

Trim an excerpt to the cap without cutting a word in half.

A citation ending mid-word reads as corrupt, and a reader cannot tell whether the source said something else. The ellipsis is explicit so a truncated excerpt is visibly truncated rather than silently shorter than what was read.

Parameters

text

string

max?

number = MAX_CITATION_EXCERPT

Returns

string