@s4tk/xml-dom
Advanced tools
+4
-0
@@ -8,2 +8,6 @@ # Changelog | ||
| ## [0.1.2] - 2022/01/29 | ||
| ### Added | ||
| - First release. | ||
| ## [0.1.1] - 2022/01/23 | ||
@@ -10,0 +14,0 @@ ### Changed |
+1
-1
| { | ||
| "name": "@s4tk/xml-dom", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "main": "xml.js", | ||
@@ -5,0 +5,0 @@ "repository": { |
+10
-0
@@ -103,2 +103,11 @@ /// <reference types="node" /> | ||
| /** | ||
| * Finds and returns the first child that has the given name. If no children | ||
| * have this name, undefined is returned. If this node cannot have children, | ||
| * an exception is thrown. | ||
| * | ||
| * @param name Name attribute of child to find | ||
| * @throws If this node cannot have children | ||
| */ | ||
| findChild(name: string): XmlNode; | ||
| /** | ||
| * Sorts the children of this node using the provided function. If no function | ||
@@ -166,2 +175,3 @@ * is given, they are sorted in ascending alphanumeric order by their `n` | ||
| deepSort(compareFn?: (a: XmlNode, b: XmlNode) => number): void; | ||
| findChild(name: string): XmlNode; | ||
| sort(compareFn?: (a: XmlNode, b: XmlNode) => number): void; | ||
@@ -168,0 +178,0 @@ abstract toXml(options?: { |
+5
-0
@@ -105,2 +105,7 @@ "use strict"; | ||
| } | ||
| findChild(name) { | ||
| if (!this.hasChildren) | ||
| throw new Error("Cannot find child for childless node."); | ||
| return this.children.find(child => child.name === name); | ||
| } | ||
| sort(compareFn) { | ||
@@ -107,0 +112,0 @@ this._ensureChildren(); |
33307
1.95%637
2.41%