Constructors

Methods

  • Applies a list of replacements to the original content using a multi-step matching strategy.

    Parameters

    • originalContent: string

      The original file content.

    • replacements: Replacement[]

      Array of Replacement objects.

    Returns {
        errors: string[];
        updatedContent: string;
    }

    An object containing the updated content and any error messages.

    • errors: string[]
    • updatedContent: string
  • Finds all exact matches of a substring within a string.

    Parameters

    • content: string

      The content to search within.

    • search: string

      The substring to search for.

    Returns number[]

    An array of starting indices where the exact substring is found.

  • Attempts to find matches by trimming whitespace from lines in the original content and the search string.

    Parameters

    • content: string

      The original content.

    • search: string

      The substring to search for, potentially with varying whitespace.

    Returns number[]

    An array of starting indices where a trimmed match is found.

  • Calculates the starting index of a specific line number in the content.

    Parameters

    • content: string

      The original content.

    • lineNumber: number

      The zero-based line number.

    Returns number

    The starting index of the specified line.

  • Replaces all occurrences of oldContent with newContent in the content.

    Parameters

    • content: string

      The original content.

    • oldContent: string

      The content to be replaced.

    • newContent: string

      The content to replace with.

    Returns string

    The content after all replacements.

  • Replaces the first occurrence of oldContent with newContent in the content.

    Parameters

    • content: string

      The original content.

    • oldContent: string

      The content to be replaced.

    • newContent: string

      The content to replace with.

    Returns string

    The content after replacement.