Skip to content

Commit 81825b0

Browse files
authored
Merge pull request #47 from Marcono1234/patch-1
Improve README
2 parents db51ca1 + 98a453f commit 81825b0

File tree

1 file changed

+43
-41
lines changed

1 file changed

+43
-41
lines changed

README.md

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ JSONC is JSON with JavaScript style comments. This node module provides a scanne
2121
Installation
2222
------------
2323

24-
npm install --save jsonc-parser
25-
26-
24+
```
25+
npm install --save jsonc-parser
26+
```
27+
2728
API
2829
---
2930

@@ -34,7 +35,7 @@ API
3435
* Creates a JSON scanner on the given text.
3536
* If ignoreTrivia is set, whitespaces or comments are ignored.
3637
*/
37-
export function createScanner(text:string, ignoreTrivia:boolean = false):JSONScanner;
38+
export function createScanner(text: string, ignoreTrivia: boolean = false): JSONScanner;
3839

3940
/**
4041
* The scanner object, representing a JSON scanner at a position in the input string.
@@ -57,7 +58,7 @@ export interface JSONScanner {
5758
*/
5859
getToken(): SyntaxKind;
5960
/**
60-
* Returns the last read token value. The value for strings is the decoded string content. For numbers its of type number, for boolean it's true or false.
61+
* Returns the last read token value. The value for strings is the decoded string content. For numbers it's of type number, for boolean it's true or false.
6162
*/
6263
getTokenValue(): string;
6364
/**
@@ -174,6 +175,7 @@ export declare function stripComments(text: string, replaceCh?: string): string;
174175
export declare function getLocation(text: string, position: number): Location;
175176

176177
export declare type Segment = string | number;
178+
export declare type JSONPath = Segment[];
177179
export interface Location {
178180
/**
179181
* The previous property key or literal value (string, number, boolean or null) or undefined.
@@ -183,13 +185,13 @@ export interface Location {
183185
* The path describing the location in the JSON document. The path consists of a sequence strings
184186
* representing an object property or numbers for array indices.
185187
*/
186-
path: Segment[];
188+
path: JSONPath;
187189
/**
188190
* Matches the locations path against a pattern consisting of strings (for properties) and numbers (for array indices).
189191
* '*' will match a single segment, of any property name or index.
190-
* '**' will match a sequece of segments or no segment, of any property name or index.
192+
* '**' will match a sequence of segments or no segment, of any property name or index.
191193
*/
192-
matches: (patterns: Segment[]) => boolean;
194+
matches: (patterns: JSONPath) => boolean;
193195
/**
194196
* If set, the location's offset is at a property key.
195197
*/
@@ -209,7 +211,7 @@ export function findNodeAtOffset(root: Node, offset: number, includeRightBound?:
209211
/**
210212
* Gets the JSON path of the given JSON DOM node
211213
*/
212-
export function getNodePath(node: Node) : JSONPath;
214+
export function getNodePath(node: Node): JSONPath;
213215

214216
/**
215217
* Evaluates the JavaScript object of the given JSON DOM node
@@ -257,47 +259,47 @@ export function applyEdits(text: string, edits: Edit[]): string;
257259
* Represents a text modification
258260
*/
259261
export interface Edit {
260-
/**
261-
* The start offset of the modification.
262-
*/
263-
offset: number;
264-
/**
265-
* The length of the modification. Must not be negative. Empty length represents an *insert*.
266-
*/
267-
length: number;
268-
/**
269-
* The new content. Empty content represents a *remove*.
270-
*/
271-
content: string;
262+
/**
263+
* The start offset of the modification.
264+
*/
265+
offset: number;
266+
/**
267+
* The length of the modification. Must not be negative. Empty length represents an *insert*.
268+
*/
269+
length: number;
270+
/**
271+
* The new content. Empty content represents a *remove*.
272+
*/
273+
content: string;
272274
}
273275

274276
/**
275277
* A text range in the document
276278
*/
277279
export interface Range {
278-
/**
279-
* The start offset of the range.
280-
*/
281-
offset: number;
282-
/**
283-
* The length of the range. Must not be negative.
284-
*/
285-
length: number;
280+
/**
281+
* The start offset of the range.
282+
*/
283+
offset: number;
284+
/**
285+
* The length of the range. Must not be negative.
286+
*/
287+
length: number;
286288
}
287289

288290
export interface FormattingOptions {
289-
/**
290-
* If indentation is based on spaces (`insertSpaces` = true), then what is the number of spaces that make an indent?
291-
*/
292-
tabSize: number;
293-
/**
294-
* Is indentation based on spaces?
295-
*/
296-
insertSpaces: boolean;
297-
/**
298-
* The default 'end of line' character
299-
*/
300-
eol: string;
291+
/**
292+
* If indentation is based on spaces (`insertSpaces` = true), then what is the number of spaces that make an indent?
293+
*/
294+
tabSize: number;
295+
/**
296+
* Is indentation based on spaces?
297+
*/
298+
insertSpaces: boolean;
299+
/**
300+
* The default 'end of line' character
301+
*/
302+
eol: string;
301303
}
302304

303305
```

0 commit comments

Comments
 (0)