ChemPal Documentation - v1.7.0
    Preparing search index...

    Function truncate

    • Truncates text to a character budget, appending a marker (and a note that the full detail is on the clipboard) when it has to cut.

      Parameters

      • text: string

        The text to bound.

      • limit: number

        Maximum length to keep.

      Returns string

      The original text, or a truncated copy with a marker.

      truncate("a".repeat(10), 4); // => "aaaa\n…[truncated — full log copied to clipboard]"
      
      export function truncate(text: string, limit: number): string {
      if (text.length <= limit) return text;
      return `${text.slice(0, limit)}\n…[truncated — full log copied to clipboard]`;
      }