cavalion-js 1.0.78 → 1.0.79

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/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 2024/07/07 - 1.0.79
2
+
3
+ * Removes `Array.prototype.last` and -`first`
4
+ * Improves beautifying XML sources and error detection during (uhm)
5
+
1
6
  ### 2024/05/16 - 1.0.78
2
7
 
3
8
  * Adds Array.fn.nonNil
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cavalion-js",
3
- "version": "1.0.78",
3
+ "version": "1.0.79",
4
4
  "description": "Cavalion common JavaScript library",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -74,16 +74,16 @@ define(function(require) {
74
74
  Array.prototype.remove = remove;
75
75
  }
76
76
  }
77
- if(Array.prototype.last === undefined) {
78
- Array.prototype.last = function() {
79
- return this[this.length - 1];
80
- };
81
- }
82
- if(Array.prototype.first === undefined) {
83
- Array.prototype.first = function() {
84
- return this[0];
85
- };
86
- }
77
+ // if(Array.prototype.last === undefined) {
78
+ // Array.prototype.last = function() {
79
+ // return this[this.length - 1];
80
+ // };
81
+ // }
82
+ // if(Array.prototype.first === undefined) {
83
+ // Array.prototype.first = function() {
84
+ // return this[0];
85
+ // };
86
+ // }
87
87
 
88
88
  Array.as = function(arrObjOrNull) {
89
89
  if(arrObjOrNull instanceof Array) {
package/src/util/Xml.js CHANGED
@@ -20,12 +20,17 @@ define(function() {
20
20
  xsltProcessor.importStylesheet(xsltDoc);
21
21
  var resultDoc = xsltProcessor.transformToDocument(xmlDoc);
22
22
  var resultXml = new XMLSerializer().serializeToString(resultDoc);
23
- return resultXml;
23
+
24
+ if(resultXml.indexOf('<parsererror ') !== -1) {
25
+ return sourceXml;
26
+ }
27
+
28
+ return resultXml.replace(/^( {2})+/gm, match => '\t'.repeat(match.length / 2));
24
29
  };
25
30
 
26
31
  var Xml = {
27
- beautify: prettifyXml,
28
- beautify_(xml) {
32
+ beautify_2: prettifyXml,
33
+ beautify_1(xml) {
29
34
  var formatted = "";
30
35
  var reg = /(>)(<)(\/*)/g;
31
36
  xml = xml.replace(reg, "$1\n$2$3");
@@ -54,6 +59,9 @@ define(function() {
54
59
  });
55
60
 
56
61
  return formatted;
62
+ },
63
+ beautify(xml) {
64
+ return Xml.beautify_2(Xml.beautify_1(xml));
57
65
  },
58
66
  jsonfy(node, opts, r) {
59
67
  if(node.getAttributeNames) {