Member Junction
    Preparing search index...

    Shared text extraction utilities.

    Provides static methods for extracting clean text from various content formats. These utilities are intentionally dependency-light — they use regex-based extraction rather than heavy DOM parsing libraries, making them suitable for server-side use without browser dependencies.

    Index

    Constructors

    Methods

    • Detect content type from a MIME type string and extract text accordingly.

      Currently supports:

      • text/html → ExtractFromHTML
      • text/plain → ExtractFromPlainText
      • text/* → ExtractFromPlainText (fallback)

      For binary formats (PDF, DOCX, etc.), callers should use dedicated libraries (pdf-parse, officeparser) and then pass the extracted text through ExtractFromPlainText.

      Parameters

      • content: string
      • mimeType: string

      Returns string

    • Extract readable text from HTML content. Strips tags, decodes entities, normalizes whitespace.

      Parameters

      • html: string

      Returns string

    • Extract and normalize plain text. Trims, normalizes whitespace, and removes control characters.

      Parameters

      • text: string

      Returns string

    • Truncate text to a maximum token count (estimated). Truncates at the last whitespace boundary before the limit.

      Parameters

      • text: string
      • maxTokens: number

      Returns string