Skip to content

Commit 4756ca6

Browse files
committed
Optimize xml-parser isArray
1 parent c3dcfc8 commit 4756ca6

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/parsers/interlinearXmlParser.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ export class InterlinearXmlParser {
187187
* Verses items, Cluster, Punctuation, and Lexeme.
188188
*/
189189
constructor() {
190+
const arrayPaths = new Set([
191+
'InterlinearData.Verses.item',
192+
'InterlinearData.Verses.item.VerseData.Cluster',
193+
'InterlinearData.Verses.item.VerseData.Punctuation',
194+
'InterlinearData.Verses.item.VerseData.Cluster.Lexeme',
195+
]);
196+
190197
const options: Partial<X2jOptions> = {
191198
ignoreAttributes: false,
192199
attributeNamePrefix: '@_',
@@ -195,14 +202,7 @@ export class InterlinearXmlParser {
195202
trimValues: true,
196203
parseTagValue: false,
197204
parseAttributeValue: false,
198-
isArray: (_tagName, jPath) => {
199-
return [
200-
'InterlinearData.Verses.item',
201-
'InterlinearData.Verses.item.VerseData.Cluster',
202-
'InterlinearData.Verses.item.VerseData.Punctuation',
203-
'InterlinearData.Verses.item.VerseData.Cluster.Lexeme',
204-
].includes(jPath);
205-
},
205+
isArray: (_tagName, jPath) => arrayPaths.has(jPath),
206206
};
207207
this.parser = new XMLParser(options);
208208
}

0 commit comments

Comments
 (0)