Class: Document
A document is a collection of zero or mode Nodes
Constructors
new Document()
new Document(
nodes
?):Document
Parameters
• nodes?: Node
[] = []
Returns
Defined in
Properties
nodes
nodes:
Node
[]
The nodes in this document
Defined in
trailing
trailing:
undefined
|string
Trailing whitespace
Defined in
Methods
appendNode()
appendNode(
node
):void
Add the given node at the end of this document
Parameters
Returns
void
Defined in
clone()
clone():
Document
Create an identical copy of this document
Returns
Defined in
findNodeByName()
findNodeByName(
name
):undefined
|Node
Return the last node in this document with the given name
This function returns the last node instead of first to be in line with how properties are defined in the KDL specification where the last property with the given name is used and the rest is shadowed.
Parameters
• name: string
Returns
undefined
| Node
Defined in
findNodesByName()
findNodesByName(
name
):Node
[]
Return all nodes with the given node name
Changes to the returned array are not reflected back onto this document itself, and updates to the document won't reflect in the returned array.
Parameters
• name: string
Returns
Node
[]
Defined in
findParameterizedNode()
findParameterizedNode(
name
,parameter
?):undefined
|Node
Return the last node in this document with the given name, matching the parameter
If the parameter is undefined
, this method looks for a node with any single
arguments. If a parameter is passed, this method looks for a node with
a single parameter, equal to the given parameter.
Parameters
• name: string
• parameter?: null
| string
| number
| boolean
Returns
undefined
| Node
Defined in
insertNodeAfter()
insertNodeAfter(
newNode
,referenceNode
):void
Insert the given node to the document after the referenceNode, or at the beginning if no reference is passed
Parameters
• referenceNode: null
| Node
Returns
void
Throws
If the given referenceNode is not part of this document
Defined in
insertNodeBefore()
insertNodeBefore(
newNode
,referenceNode
):void
Insert the given node to the document before the referenceNode, or at the end if no reference is passed
Parameters
• referenceNode: null
| Node
Returns
void
Throws
If the given referenceNode is not part of this document
Defined in
isEmpty()
isEmpty():
boolean
Return whether the document is empty
Returns
boolean
Defined in
removeNode()
removeNode(
node
):void
Remove the given node from this document
Parameters
• node: Node
Returns
void
Throws
if the given node is not in this document
Defined in
removeNodesByName()
removeNodesByName(
name
):void
Remove all nodes with the given name from this document
Parameters
• name: string
Returns
void
Defined in
replaceNode()
replaceNode(
oldNode
,newNode
):void
Replace the old node with the new node in this document
Parameters
• oldNode: Node
Returns
void
Throws
if the oldNode is not in this document