• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NaturalIntelligence / fast-xml-parser / 14973142022

12 May 2025 01:11PM UTC coverage: 97.547%. Remained the same
14973142022

push

github

web-flow
export types in fxp.d.ts for better module usability (#744)

1090 of 1134 branches covered (96.12%)

8908 of 9132 relevant lines covered (97.55%)

488239.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.5
/src/xmlparser/xmlNode.js
1
'use strict';
5✔
2

5✔
3
let METADATA_SYMBOL;
5✔
4

5✔
5
if (typeof Symbol !== "function") {
5!
6
  METADATA_SYMBOL = "@@xmlMetadata";
×
7
} else {
5✔
8
  METADATA_SYMBOL = Symbol("XML Node Metadata");
5✔
9
}
5✔
10

5✔
11
export default class XmlNode{
5✔
12
  constructor(tagname) {
5✔
13
    this.tagname = tagname;
4,495✔
14
    this.child = []; //nested tags, text, cdata, comments in order
4,495✔
15
    this[":@"] = {}; //attributes map
4,495✔
16
  }
4,495✔
17
  add(key,val){
5✔
18
    // this.child.push( {name : key, val: val, isCdata: isCdata });
2,350✔
19
    if(key === "__proto__") key = "#__proto__";
2,350!
20
    this.child.push( {[key]: val });
2,350✔
21
  }
2,350✔
22
  addChild(node, startIndex) {
5✔
23
    if(node.tagname === "__proto__") node.tagname = "#__proto__";
3,625!
24
    if(node[":@"] && Object.keys(node[":@"]).length > 0){
3,625✔
25
      this.child.push( { [node.tagname]: node.child, [":@"]: node[":@"] });
815✔
26
    }else{
3,625✔
27
      this.child.push( { [node.tagname]: node.child });
2,810✔
28
    }
2,810✔
29
    // if requested, add the startIndex
3,625✔
30
    if (startIndex !== undefined) {
3,625✔
31
      // Note: for now we just overwrite the metadata. If we had more complex metadata,
85✔
32
      // we might need to do an object append here:  metadata = { ...metadata, startIndex }
85✔
33
      this.child[this.child.length - 1][METADATA_SYMBOL] = { startIndex };
85✔
34
    }
85✔
35
  }
3,625✔
36
  /** symbol used for metadata */
5✔
37
  static getMetaDataSymbol() {
5✔
38
    return METADATA_SYMBOL;
10✔
39
  }
10✔
40
}
5✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc