MCPcopy Create free account
hub / github.com/observablehq/framework / positionLength

Function positionLength

src/sourcemap.ts:118–127  ·  view source on GitHub ↗
(input: string, start = 0, end = input.length)

Source from the content-addressed store, hash-verified

116}
117
118function positionLength(input: string, start = 0, end = input.length): Position {
119 let match: RegExpExecArray;
120 let line = 0;
121 lineBreakG.lastIndex = start;
122 while ((match = lineBreakG.exec(input)) && match.index < end) {
123 ++line;
124 start = match.index + match[0].length;
125 }
126 return {line, column: end - start};
127}
128
129function positionSubtract(b: Position, a: Position): Position {
130 return b.line === a.line ? {line: 0, column: b.column - a.column} : {line: b.line - a.line, column: b.column};

Callers 1

translateMethod · 0.85

Calls 1

execMethod · 0.45

Tested by

no test coverage detected