Skip to main content
Latest
function createPositionQuery
import { createPositionQuery } from "https://deno.land/x/leac@v0.6.0/positionQuery.ts";

Create a function that will return a position (line and column number) based on offset (index) within the string.

Matches all linebreaks (\n) on creation and then uses a binary tree to compute the position on each call.

Parameters

str: string
  • Input string.

Returns

(offset: number) => Position