/**
 * Provides a debug display of a position inside of a string - inserts the given text at the given position,
 * and truncates the beginning and end of a long string.
 */ export function __debugMarkPositionInString ( text , position , insertTextAtPosition = '<CURSOR>' , charactersBeforePosition = 70 , charactersAfterPosition = 70 ) { if ( position >= text . length ) { const textAtEnd = `${ text . slice ( text . length - charactersAfterPosition ) }<END(${ text . length })>` ; return `${ textAtEnd }...<CURSOR=${ position }>` ; } const preTextIndex = position - charactersBeforePosition ; const preText = `${ ( preTextIndex > 0 ? "..." : "" ) }${ text . slice ( preTextIndex >= 0 ? preTextIndex : 0 , position ) }` ; const postStart = position ; const postTextIndex = text . slice ( postStart , postStart + charactersAfterPosition ) + ( postStart > charactersAfterPosition ? "..." : "" ) ; return `${ preText }${ insertTextAtPosition }${ postTextIndex }` ; } /**
 * Same as __debugMarkPositionInString, but specifying a range instead of a position
 */ export function __debugMarkRangeInString ( text , position , length , leftMarker = "<<" , rightMarker = ">>" , charactersBeforePosition = 25 , charactersAfterPosition = 50 ) { if ( position >= text . length ) { return __debugMarkPositionInString ( text , position , leftMarker + rightMarker , charactersBeforePosition , charactersAfterPosition ) ; } const preTextIndex = position - charactersBeforePosition ; const preText = `${ ( preTextIndex > 0 ? "..." : "" ) }${ text . slice ( preTextIndex >= 0 ? preTextIndex : 0 , position ) }` ; const postTextIndex = position + length ; const postText = text . slice ( postTextIndex , postTextIndex + charactersAfterPosition ) + ( postTextIndex > charactersAfterPosition ? "..." : "" ) ; return `${ preText }${ leftMarker }${ text . slice ( position , position + length ) }${ rightMarker }${ postText }` ; }