moderator-toolbox-nxg-for-reddit / util/data/positionalJson
util/data/positionalJson¶
Functions¶
offsetToLine()¶
offsetToLine(
text,offset):number
Defined in: extension/data/util/data/positionalJson.ts:223
Converts a character offset to a 1-based line number, for error messages in contexts without a line-aware editor.
Parameters¶
text¶
string
The source text.
offset¶
number
The character offset.
Returns¶
number
parsePositionalJson()¶
parsePositionalJson(
text):PositionalJsonResult
Defined in: extension/data/util/data/positionalJson.ts:57
Parses JSON text, recording the source span of every node.
Parameters¶
text¶
string
The JSON document.
Returns¶
Throws¶
When the text is not valid JSON.
Classes¶
JsonSyntaxError¶
Defined in: extension/data/util/data/positionalJson.ts:39
A JSON syntax error with the source offset where parsing failed.
Extends¶
Error
Constructors¶
Constructor¶
new JsonSyntaxError(
message,position):JsonSyntaxError
Defined in: extension/data/util/data/positionalJson.ts:43
Parameters¶
message¶
string
position¶
number
Returns¶
Overrides¶
Error.constructor
Methods¶
isError()¶
staticisError(error):error is Error
Defined in: node_modules/typescript/lib/lib.esnext.error.d.ts:21
Indicates whether the argument provided is a built-in Error instance or not.
Parameters¶
error¶
unknown
Returns¶
error is Error
Inherited from¶
Error.isError
Properties¶
cause?¶
optionalcause?:unknown
Defined in: node_modules/typescript/lib/lib.es2022.error.d.ts:24
Inherited from¶
Error.cause
message¶
message:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1075
Inherited from¶
Error.message
name¶
name:
string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1074
Inherited from¶
Error.name
position¶
position:
number
Defined in: extension/data/util/data/positionalJson.ts:41
Character offset of the offending position in the source text.
stack?¶
optionalstack?:string
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from¶
Error.stack
Interfaces¶
JsonSpan¶
Defined in: extension/data/util/data/positionalJson.ts:18
The character span of one JSON node in the source text.
Properties¶
from¶
from:
number
Defined in: extension/data/util/data/positionalJson.ts:20
Offset of the node’s first character.
to¶
to:
number
Defined in: extension/data/util/data/positionalJson.ts:22
Offset just past the node’s last character.
PositionalJsonResult¶
Defined in: extension/data/util/data/positionalJson.ts:26
A successfully parsed document with per-node source spans.
Properties¶
spans¶
spans:
Map<string,JsonSpan>
Defined in: extension/data/util/data/positionalJson.ts:35
Source span of every node, keyed by path: '' is the root, object
members append .key, array elements append .index (no leading dot
at the root, so a top-level key a has path 'a').
value¶
value:
any
Defined in: extension/data/util/data/positionalJson.ts:29
The parsed value, identical to JSON.parse output.