MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / offsetToLineCol

Function offsetToLineCol

src/platform/node-hyperscript.js:254–261  ·  view source on GitHub ↗
(text, offset)

Source from the content-addressed store, hash-verified

252}
253
254function offsetToLineCol(text, offset) {
255 let line = 1, col = 1;
256 for (let i = 0; i < offset && i < text.length; i++) {
257 if (text[i] === '\n') { line++; col = 1; }
258 else col++;
259 }
260 return { line, col };
261}
262
263// ===== Utilities =====
264

Callers 1

formatErrorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected