Skip to content

Commit 3c101d7

Browse files
committed
Rename startParse to parse
1 parent d6303f5 commit 3c101d7

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

src/lib/Parser.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,17 @@ export class Parser {
3131
*/
3232
constructor(xml: string, options: ParserOptions = {}) {
3333
let doc = this.document = new XmlDocument();
34-
this.scanner = new StringScanner(xml);
3534

3635
this.currentNode = doc;
3736
this.options = options;
37+
this.scanner = new StringScanner(xml);
3838

3939
if (this.options.includeOffsets) {
4040
doc.start = 0;
4141
doc.end = xml.length;
4242
}
4343

44-
this.startParse();
45-
}
46-
47-
startParse() {
48-
this.scanner.consumeString('\uFEFF'); // byte order mark
49-
this.consumeProlog();
50-
51-
if (!this.consumeElement()) {
52-
throw this.error('Root element is missing or invalid');
53-
}
54-
55-
while (this.consumeMisc()) {} // eslint-disable-line no-empty
56-
57-
if (!this.scanner.isEnd) {
58-
throw this.error('Extra content at the end of the document');
59-
}
44+
this.parse();
6045
}
6146

6247
/**
@@ -782,6 +767,24 @@ export class Parser {
782767
return new XmlError(message, scanner.charIndex, scanner.string);
783768
}
784769

770+
/**
771+
* Parses the XML input.
772+
*/
773+
parse() {
774+
this.scanner.consumeString('\uFEFF'); // byte order mark
775+
this.consumeProlog();
776+
777+
if (!this.consumeElement()) {
778+
throw this.error('Root element is missing or invalid');
779+
}
780+
781+
while (this.consumeMisc()) {} // eslint-disable-line no-empty
782+
783+
if (!this.scanner.isEnd) {
784+
throw this.error('Extra content at the end of the document');
785+
}
786+
}
787+
785788
/**
786789
* Throws an invalid character error if any character in the given _string_
787790
* isn't a valid XML character.

0 commit comments

Comments
 (0)