PromptShield logo PromptShield
API DocsFunctions

getLocForIndex()

getLocForIndex(index, context): object

Defined in: utils.ts:44

Resolves a character index into a line/column location.

Uses binary search over precomputed line offsets for O(log n) lookup.

Context provides:

  • baseLine
  • baseCol
  • lineOffsets

baseLine and baseCol allow this function to operate correctly when scanning substrings that originate from a larger document.

Parameters

index

number

context

Required<ScanContext>

Returns

column

column: number

index

index: number

line

line: number

On this page