Skip to content

Commit

Permalink
Merge pull request #47 from Marcono1234/patch-1
Browse files Browse the repository at this point in the history
Improve README
  • Loading branch information
aeschli committed Oct 25, 2021
2 parents db51ca1 + 98a453f commit 81825b0
Showing 1 changed file with 43 additions and 41 deletions.
84 changes: 43 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ JSONC is JSON with JavaScript style comments. This node module provides a scanne
Installation
------------

npm install --save jsonc-parser


```
npm install --save jsonc-parser
```

API
---

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

/**
* The scanner object, representing a JSON scanner at a position in the input string.
Expand All @@ -57,7 +58,7 @@ export interface JSONScanner {
*/
getToken(): SyntaxKind;
/**
* 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.
* 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.
*/
getTokenValue(): string;
/**
Expand Down Expand Up @@ -174,6 +175,7 @@ export declare function stripComments(text: string, replaceCh?: string): string;
export declare function getLocation(text: string, position: number): Location;

export declare type Segment = string | number;
export declare type JSONPath = Segment[];
export interface Location {
/**
* The previous property key or literal value (string, number, boolean or null) or undefined.
Expand All @@ -183,13 +185,13 @@ export interface Location {
* The path describing the location in the JSON document. The path consists of a sequence strings
* representing an object property or numbers for array indices.
*/
path: Segment[];
path: JSONPath;
/**
* Matches the locations path against a pattern consisting of strings (for properties) and numbers (for array indices).
* '*' will match a single segment, of any property name or index.
* '**' will match a sequece of segments or no segment, of any property name or index.
* '**' will match a sequence of segments or no segment, of any property name or index.
*/
matches: (patterns: Segment[]) => boolean;
matches: (patterns: JSONPath) => boolean;
/**
* If set, the location's offset is at a property key.
*/
Expand All @@ -209,7 +211,7 @@ export function findNodeAtOffset(root: Node, offset: number, includeRightBound?:
/**
* Gets the JSON path of the given JSON DOM node
*/
export function getNodePath(node: Node) : JSONPath;
export function getNodePath(node: Node): JSONPath;

/**
* Evaluates the JavaScript object of the given JSON DOM node
Expand Down Expand Up @@ -257,47 +259,47 @@ export function applyEdits(text: string, edits: Edit[]): string;
* Represents a text modification
*/
export interface Edit {
/**
* The start offset of the modification.
*/
offset: number;
/**
* The length of the modification. Must not be negative. Empty length represents an *insert*.
*/
length: number;
/**
* The new content. Empty content represents a *remove*.
*/
content: string;
/**
* The start offset of the modification.
*/
offset: number;
/**
* The length of the modification. Must not be negative. Empty length represents an *insert*.
*/
length: number;
/**
* The new content. Empty content represents a *remove*.
*/
content: string;
}

/**
* A text range in the document
*/
export interface Range {
/**
* The start offset of the range.
*/
offset: number;
/**
* The length of the range. Must not be negative.
*/
length: number;
/**
* The start offset of the range.
*/
offset: number;
/**
* The length of the range. Must not be negative.
*/
length: number;
}

export interface FormattingOptions {
/**
* If indentation is based on spaces (`insertSpaces` = true), then what is the number of spaces that make an indent?
*/
tabSize: number;
/**
* Is indentation based on spaces?
*/
insertSpaces: boolean;
/**
* The default 'end of line' character
*/
eol: string;
/**
* If indentation is based on spaces (`insertSpaces` = true), then what is the number of spaces that make an indent?
*/
tabSize: number;
/**
* Is indentation based on spaces?
*/
insertSpaces: boolean;
/**
* The default 'end of line' character
*/
eol: string;
}

```
Expand Down

0 comments on commit 81825b0

Please sign in to comment.