phylotree 2.1.5 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phylotree",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "main": "dist/phylotree.js",
5
5
  "unpkg": "dist/phylotree.js",
6
6
  "jsdelivr": "dist/phylotree.js",
@@ -32,8 +32,7 @@
32
32
  "pretty-data": "^0.40.0",
33
33
  "rollup-plugin-node-resolve": "^5.2.0",
34
34
  "underscore": "1.x",
35
- "winston": "^3.2.1",
36
- "xml2js": "^0.6.2"
35
+ "winston": "^3.2.1"
37
36
  },
38
37
  "devDependencies": {
39
38
  "@rollup/plugin-commonjs": "^28.0.6",
@@ -46,7 +45,6 @@
46
45
  "rollup": "^2.50.6",
47
46
  "rollup-plugin-copy": "^3.3.0",
48
47
  "rollup-plugin-execute": "^1.1.1",
49
- "rollup-plugin-polyfill-node": "^0.13.0",
50
48
  "rollup-plugin-terser": "^7.0.2",
51
49
  "rollup-watch": "^3.2.2",
52
50
  "tape": "5.2.2",
@@ -1,11 +1,16 @@
1
1
  import * as _ from "underscore";
2
- import * as xml2js from "xml2js";
2
+ import { XMLParser } from "fast-xml-parser";
3
3
 
4
4
  var nexml_parser = function(xml_string, options) {
5
- var trees;
6
- xml2js.parseString(xml_string, function(error, xml) {
7
- trees = xml["nex:nexml"].trees[0].tree.map(function(nexml_tree) {
8
- var node_list = nexml_tree.node.map(d => d.$),
5
+ const parser = new XMLParser({
6
+ ignoreAttributes: false,
7
+ attributeNamePrefix: "",
8
+ parseAttributeValue: true
9
+ });
10
+
11
+ const xml = parser.parse(xml_string);
12
+ var trees = xml["nex:nexml"].trees.tree.map(function(nexml_tree) {
13
+ var node_list = nexml_tree.node.map(d => d),
9
14
  node_hash = node_list.reduce(function(a, b) {
10
15
  b.edges = [];
11
16
  b.name = b.id;
@@ -16,7 +21,7 @@ var nexml_parser = function(xml_string, options) {
16
21
  root_id = roots > 0 ? roots[0].id : node_list[0].id;
17
22
  node_hash[root_id].name = "root";
18
23
 
19
- nexml_tree.edge.map(d => d.$).forEach(function(edge) {
24
+ nexml_tree.edge.map(d => d).forEach(function(edge) {
20
25
  node_hash[edge.source].edges.push(edge);
21
26
  });
22
27
 
@@ -35,7 +40,6 @@ var nexml_parser = function(xml_string, options) {
35
40
  parseNexml(node_hash[root_id]);
36
41
  return node_hash[root_id];
37
42
  });
38
- });
39
43
  return trees;
40
44
  };
41
45