Skip to content

Commit 374d2d1

Browse files
committed
Add offset and length to JsonNode
1 parent 5f92eca commit 374d2d1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/instance.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export const cons: (
99
value: Json,
1010
type: JsonNodeType,
1111
children: JsonNode[],
12-
parent?: JsonNode
12+
parent?: JsonNode,
13+
offset?: number,
14+
textLength?: number
1315
) => JsonNode;
1416
export const get: (url: string, context: JsonNode) => JsonNode | undefined;
1517
export const uri: (node: JsonNode) => string;
@@ -35,6 +37,8 @@ export type JsonNode = {
3537
valid: boolean;
3638
errors: Record<string, string>;
3739
annotations: Record<string, Record<string, unknown>>;
40+
offset?: number;
41+
textLength?: number;
3842
};
3943

4044
type JsonNodeType = "object" | "array" | "string" | "number" | "boolean" | "null" | "property";

lib/instance.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ export const fromJs = (value, uri = "", pointer = "", parent = undefined) => {
4040
}
4141
};
4242

43-
export const cons = (baseUri, pointer, value, type, children, parent) => {
43+
export const cons = (baseUri, pointer, value, type, children, parent, offset, textLength) => {
4444
const node = {
4545
baseUri: baseUri ? toAbsoluteIri(baseUri) : "",
4646
pointer: pointer,
4747
value: value,
4848
type: type,
4949
children: children,
5050
parent: parent,
51+
offset: offset,
52+
textLength: textLength,
5153
valid: true,
5254
errors: {},
5355
annotations: {}

0 commit comments

Comments
 (0)