PromptShield logo PromptShield
API DocsFunctions

getLineOffsets()

getLineOffsets(text): number[]

Defined in: utils.ts:19

Computes line start offsets for a string.

Each entry represents the character index where a new line begins. The first entry is always 0.

Example: "a\nb\nc" → [0, 2, 4]

This enables fast index → (line, column) mapping without repeatedly scanning the entire string.

Parameters

text

string

Returns

number[]

On this page