MCPcopy Create free account
hub / github.com/EsperoTech/yaade / getErrorPosition

Function getErrorPosition

client/src/utils/codemirror/lang-json/index.js:30–37  ·  view source on GitHub ↗
(error, doc)

Source from the content-addressed store, hash-verified

28 return [];
29};
30function getErrorPosition(error, doc) {
31 let m;
32 if (m = error.message.match(/at position (\d+)/))
33 return Math.min(+m[1], doc.length);
34 if (m = error.message.match(/at line (\d+) column (\d+)/))
35 return Math.min(doc.line(+m[1]).from + (+m[2]) - 1, doc.length);
36 return 0;
37}
38
39/**
40A language provider that provides JSON parsing.

Callers 1

jsonParseLinterFunction · 0.85

Calls 1

minMethod · 0.80

Tested by

no test coverage detected