MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / getLine

Function getLine

src/common/parser.ts:58–72  ·  view source on GitHub ↗
(line: number)

Source from the content-addressed store, hash-verified

56 }
57
58 getLine(line: number): string | undefined {
59 if (line < 1) return undefined; // Lines are 1-indexed
60 let currentLine = 1;
61 let start = 0;
62 while (currentLine < line && start < this.buffer.length) {
63 const nextNewline = this.buffer.indexOf('\n', start);
64 if (nextNewline === -1) break; // No more lines
65 start = nextNewline + 1; // Move past the newline character
66 currentLine++;
67 }
68 if (currentLine !== line) return undefined; // Line not found
69 const end = this.buffer.indexOf('\n', start);
70 if (end === -1) return this.buffer.slice(start); // Last line
71 return this.buffer.slice(start, end);
72 }
73
74 error(message: string): never {
75 const { line, col } = this.lineCol;

Callers

nothing calls this directly

Calls 1

sliceMethod · 0.65

Tested by

no test coverage detected