index

Index

Classes

Interfaces

BOM

A Byte-Order Mark at the start of a document

Properties

text

text: string

The BOM text, i.e. '\ufeff'.

Defined in

src/model/whitespace.d.ts:17


type

type: "bom"

A property to differentiate the different types of whitespace

Defined in

src/model/whitespace.d.ts:12


EscLine

An escaped newline

Properties

text

text: string

The escaped newline

Defined in

src/model/whitespace.d.ts:64


type

type: "line-escape"

A property to differentiate the different types of whitespace

Defined in

src/model/whitespace.d.ts:59


InlineWhitespace

Regular plain old whitespace characters

Properties

text

text: string

The whitespace's text

Defined in

src/model/whitespace.d.ts:32


type

type: "space"

A property to differentiate the different types of whitespace

Defined in

src/model/whitespace.d.ts:27


Location

A location in the source text

Properties

column

column: number

Column in the line

The first character of the line is column number 1.

Defined in

src/parser/token.d.ts:22


line

line: number

Line number in the source text

The first line has number 1.

Defined in

src/parser/token.d.ts:16


offset

offset: number

Index of this location in the source text

The first character in the source text has offset 0.

Defined in

src/parser/token.d.ts:10


MultilineComment

A multiline comment

Properties

text

text: string

The comment text, including the comment tokens themselves

Defined in

src/model/whitespace.d.ts:79


type

type: "multiline"

A property to differentiate the different types of whitespace

Defined in

src/model/whitespace.d.ts:74


Newline

A single newline

Note a newline can consist of multiple characters: \r\n is a single newline.

Properties

text

text: string

The newline

Defined in

src/model/whitespace.d.ts:49


type

type: "newline"

A property to differentiate the different types of whitespace

Defined in

src/model/whitespace.d.ts:44


SingleLineComment

A single-line comment

Properties

text

text: string

The comment's text, starting at the // and ending with a newline unless the comment ended at the end of the file

Defined in

src/model/whitespace.d.ts:94


type

type: "singleline"

A property to differentiate the different types of whitespace

Defined in

src/model/whitespace.d.ts:89


SlashDashInDocument

A slashdash comment in a document, i.e. a slashdash commented node

Properties

preface

preface: NodeSpace[]

Any whitespace between the slashdash token and the value

Defined in

src/model/whitespace.d.ts:146


type

type: "slashdash"

A property to differentiate the different types of whitespace

Defined in

src/model/whitespace.d.ts:141


value

value: Node

The escaped value

Defined in

src/model/whitespace.d.ts:151


SlashDashInNode

A slashdash comment inside a node, i.e. a slashdash commented argument, property, or child block

Properties

preface

preface: NodeSpace[]

Any whitespace between the slashdash token and the value

Defined in

src/model/whitespace.d.ts:121


type

type: "slashdash"

A property to differentiate the different types of whitespace

Defined in

src/model/whitespace.d.ts:116


value

value: Entry | Document

The escaped value

Defined in

src/model/whitespace.d.ts:126


StoredLocation

Stored location of a Document, Entry, Identifier, Node, Tag, or Value.

Properties

end

end: Location

The location after the last character

Defined in

src/locations.js:9


start

start: Location

The location of the first character

Defined in

src/locations.js:8


Token

A single token in the KDL text

Properties

end

end: Location

The location after the last character of this token

Defined in

src/parser/token.d.ts:58


start

start: Location

The location of the first character of this token

Defined in

src/parser/token.d.ts:53


text

text: string

The text of this token

This could be computed if you have access to the source text using

sourceText.slice(token.start.offset, token.end.offset)
Defined in

src/parser/token.d.ts:48

Type Aliases

LineSpace

LineSpace: BOM | Newline | WS | SingleLineComment

A single plain whitespace item in a document, i.e. before/after/between nodes

Defined in

src/model/whitespace.d.ts:107


NodeSpace

NodeSpace: EscLine | WS

A single plain whitespace item inside of a node, e.g. between two arguments in a node.

Defined in

src/model/whitespace.d.ts:102


Primitive

Primitive<>: string | number | boolean | null

A primitive is any type that can be represented as an argument or property

Type Parameters

Type Parameter

Defined in

src/model/value.js:4


WhitespaceInDocument

WhitespaceInDocument: (LineSpace | SlashDashInDocument)[]

Whitespace in a document, i.e. before/after/between nodes

Defined in

src/model/whitespace.d.ts:157


WhitespaceInNode

WhitespaceInNode: (NodeSpace | SlashDashInNode)[]

Whitespace inside of a node, e.g. between two arguments in a node.

Defined in

src/model/whitespace.d.ts:132

Functions

clearFormat()

clearFormat<T>(v): T

Type Parameters

Type ParameterDescription
T extends Identifier | Tag | Value | Entry | Node | Document

Parameters

ParameterTypeDescription
vT

Returns

T

Defined in

src/clear-format.js:122


format()

format(v): string

Parameters

ParameterTypeDescription
vIdentifier | Tag | Value | Entry | Node | Document

Returns

string

Defined in

src/format.js:147


getLocation()

getLocation(element): undefined | StoredLocation

Get location information of the given parsed element

If the element was not created by the parser, or if the parser option storeLocations was not set to true, the result will be undefined.

Parameters

ParameterTypeDescription
elementIdentifier | Tag | Value | Entry | Node | Document

Returns

undefined | StoredLocation

Defined in

src/locations.js:26


parse()

Call Signature

parse(text, options): Value

Parse the given text as a value.

The text should not contain anything other than the value, i.e. no leading or trailing whitespace, no comments, no tags.

Parameters
ParameterType
textstring | ArrayBuffer | DataView | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
options{ as: "value"; graphemeLocations: boolean; storeLocations: boolean; }
options.as"value"
options.graphemeLocations?boolean
options.storeLocations?boolean
Returns

Value

Defined in

src/parse.d.ts:23

Call Signature

parse(text, options): Identifier

Parse the given text as a identifier.

The text should not contain anything other than the identifier, i.e. no leading or trailing whitespace, no comments, no tags.

Parameters
ParameterType
textstring | ArrayBuffer | DataView | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
options{ as: "identifier"; graphemeLocations: boolean; storeLocations: boolean; }
options.as"identifier"
options.graphemeLocations?boolean
options.storeLocations?boolean
Returns

Identifier

Defined in

src/parse.d.ts:46

Call Signature

parse(text, options): Entry

Parse the given text as an entry.

The text can contain extra whitespace, tags, and comments (though no slashdash comments of entire nodes)

Parameters
ParameterType
textstring | ArrayBuffer | DataView | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
options{ as: "entry"; graphemeLocations: boolean; storeLocations: boolean; }
options.as"entry"
options.graphemeLocations?boolean
options.storeLocations?boolean
Returns

Entry

Defined in

src/parse.d.ts:69

Call Signature

parse(text, options): Node

Parse the given text as a node.

The text can contain extra whitespace, tags, and comments.

Parameters
ParameterType
textstring | ArrayBuffer | DataView | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
options{ as: "node"; graphemeLocations: boolean; storeLocations: boolean; }
options.as"node"
options.graphemeLocations?boolean
options.storeLocations?boolean
Returns

Node

Defined in

src/parse.d.ts:91

Call Signature

parse(text, options): LineSpace

Parse the given text as a whitespace in a document.

Parameters
ParameterType
textstring | ArrayBuffer | DataView | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
options{ as: "whitespace in document"; graphemeLocations: boolean; storeLocations: boolean; }
options.as"whitespace in document"
options.graphemeLocations?boolean
options.storeLocations?boolean
Returns

LineSpace

Defined in

src/parse.d.ts:111

Call Signature

parse(text, options): NodeSpace

Parse the given text as a whitespace in a node.

Parameters
ParameterType
textstring | ArrayBuffer | DataView | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
options{ as: "whitespace in node"; graphemeLocations: boolean; storeLocations: boolean; }
options.as"whitespace in node"
options.graphemeLocations?boolean
options.storeLocations?boolean
Returns

NodeSpace

Defined in

src/parse.d.ts:131

Call Signature

parse(text, options?): Document

Parse the given text as a document.

The text can contain extra whitespace, tags, and comments.

Parameters
ParameterType
textstring | ArrayBuffer | DataView | Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array
options?{ as: "document"; graphemeLocations: boolean; storeLocations: boolean; }
options.as?"document"
options.graphemeLocations?boolean
options.storeLocations?boolean
Returns

Document

Defined in

src/parse.d.ts:153