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

NaturalIntelligence / fast-xml-parser / 14241982649

03 Apr 2025 11:33AM UTC coverage: 98.954% (+0.008%) from 98.946%
14241982649

push

github

amitguptagwl
update package detail

1112 of 1146 branches covered (97.03%)

8800 of 8893 relevant lines covered (98.95%)

501358.63 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,480✔
14
    this.child = []; //nested tags, text, cdata, comments in order
4,480✔
15
    this[":@"] = {}; //attributes map
4,480✔
16
  }
4,480✔
17
  add(key,val){
5✔
18
    // this.child.push( {name : key, val: val, isCdata: isCdata });
2,340✔
19
    if(key === "__proto__") key = "#__proto__";
2,340!
20
    this.child.push( {[key]: val });
2,340✔
21
  }
2,340✔
22
  addChild(node, startIndex) {
5✔
23
    if(node.tagname === "__proto__") node.tagname = "#__proto__";
3,615!
24
    if(node[":@"] && Object.keys(node[":@"]).length > 0){
3,615✔
25
      this.child.push( { [node.tagname]: node.child, [":@"]: node[":@"] });
815✔
26
    }else{
3,615✔
27
      this.child.push( { [node.tagname]: node.child });
2,800✔
28
    }
2,800✔
29
    // if requested, add the startIndex
3,615✔
30
    if (startIndex !== undefined) {
3,615✔
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,615✔
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