@brickhouse-tech/xml2js 0.6.3 → 1.1.3
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/lib/bom.js +7 -12
- package/lib/builder.js +119 -98
- package/lib/defaults.js +74 -71
- package/lib/parser.js +356 -342
- package/lib/processors.js +23 -29
- package/lib/xml2js.js +20 -39
- package/package.json +22 -12
package/lib/processors.js
CHANGED
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
//
|
|
2
|
-
(
|
|
3
|
-
"use strict";
|
|
4
|
-
var prefixMatch;
|
|
1
|
+
// matches all xml prefixes, except for `xmlns:`
|
|
2
|
+
const prefixMatch = new RegExp(/(?!xmlns)^.*:/);
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
export function normalize(str) {
|
|
5
|
+
return str.toLowerCase();
|
|
6
|
+
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
export function firstCharLowerCase(str) {
|
|
9
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export function stripPrefix(str) {
|
|
13
|
+
return str.replace(prefixMatch, '');
|
|
14
|
+
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export function parseNumbers(str) {
|
|
17
|
+
if (!isNaN(str)) {
|
|
18
|
+
str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str);
|
|
19
|
+
}
|
|
20
|
+
return str;
|
|
21
|
+
}
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
exports.parseBooleans = function(str) {
|
|
28
|
-
if (/^(?:true|false)$/i.test(str)) {
|
|
29
|
-
str = str.toLowerCase() === 'true';
|
|
30
|
-
}
|
|
31
|
-
return str;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
}).call(this);
|
|
23
|
+
export function parseBooleans(str) {
|
|
24
|
+
if (/^(?:true|false)$/i.test(str)) {
|
|
25
|
+
str = str.toLowerCase() === 'true';
|
|
26
|
+
}
|
|
27
|
+
return str;
|
|
28
|
+
}
|
package/lib/xml2js.js
CHANGED
|
@@ -1,39 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
extend(ValidationError, superClass);
|
|
22
|
-
|
|
23
|
-
function ValidationError(message) {
|
|
24
|
-
this.message = message;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return ValidationError;
|
|
28
|
-
|
|
29
|
-
})(Error);
|
|
30
|
-
|
|
31
|
-
exports.Builder = builder.Builder;
|
|
32
|
-
|
|
33
|
-
exports.Parser = parser.Parser;
|
|
34
|
-
|
|
35
|
-
exports.parseString = parser.parseString;
|
|
36
|
-
|
|
37
|
-
exports.parseStringPromise = parser.parseStringPromise;
|
|
38
|
-
|
|
39
|
-
}).call(this);
|
|
1
|
+
import { defaults } from './defaults.js';
|
|
2
|
+
import { Builder } from './builder.js';
|
|
3
|
+
import { Parser, parseString, parseStringPromise } from './parser.js';
|
|
4
|
+
import * as processors from './processors.js';
|
|
5
|
+
|
|
6
|
+
export { defaults };
|
|
7
|
+
export { processors };
|
|
8
|
+
|
|
9
|
+
export class ValidationError extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.message = message;
|
|
13
|
+
this.name = 'ValidationError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { Builder };
|
|
18
|
+
export { Parser };
|
|
19
|
+
export { parseString };
|
|
20
|
+
export { parseStringPromise };
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"json"
|
|
7
7
|
],
|
|
8
8
|
"homepage": "https://github.com/brickhouse-tech/node-xml2js",
|
|
9
|
-
"version": "
|
|
9
|
+
"version": "1.1.3",
|
|
10
10
|
"author": "Marek Kubica <marek@xivilization.net> (https://xivilization.net)",
|
|
11
11
|
"contributors": [
|
|
12
12
|
"maqr <maqr.lollerskates@gmail.com> (https://github.com/maqr)",
|
|
@@ -56,7 +56,13 @@
|
|
|
56
56
|
"d3adc0d3 (https://github.com/d3adc0d3)",
|
|
57
57
|
"James Crosby (https://github.com/autopulated)"
|
|
58
58
|
],
|
|
59
|
-
"
|
|
59
|
+
"type": "module",
|
|
60
|
+
"main": "./lib/xml2js.js",
|
|
61
|
+
"exports": {
|
|
62
|
+
".": "./lib/xml2js.js",
|
|
63
|
+
"./lib/parser": "./lib/parser.js",
|
|
64
|
+
"./lib/builder": "./lib/builder.js"
|
|
65
|
+
},
|
|
60
66
|
"files": [
|
|
61
67
|
"lib"
|
|
62
68
|
],
|
|
@@ -64,11 +70,9 @@
|
|
|
64
70
|
"lib": "./lib"
|
|
65
71
|
},
|
|
66
72
|
"scripts": {
|
|
67
|
-
"
|
|
68
|
-
"test": "zap",
|
|
73
|
+
"test": "mocha",
|
|
69
74
|
"lint": "eslint .",
|
|
70
|
-
"coverage": "
|
|
71
|
-
"doc": "cake doc"
|
|
75
|
+
"coverage": "c8 npm test"
|
|
72
76
|
},
|
|
73
77
|
"repository": {
|
|
74
78
|
"type": "git",
|
|
@@ -79,17 +83,23 @@
|
|
|
79
83
|
"xmlbuilder": "^15.1.1"
|
|
80
84
|
},
|
|
81
85
|
"devDependencies": {
|
|
86
|
+
"@commitlint/cli": "^20.4.2",
|
|
87
|
+
"@commitlint/config-conventional": "^20.4.2",
|
|
82
88
|
"@eslint/js": "^10.0.1",
|
|
83
|
-
"
|
|
84
|
-
"
|
|
89
|
+
"c8": "^10.1.3",
|
|
90
|
+
"commit-and-tag-version": "^12.6.1",
|
|
85
91
|
"diff": "^8.0.3",
|
|
86
|
-
"docco": "^0.9.2",
|
|
87
92
|
"eslint": "^10.0.2",
|
|
88
|
-
"
|
|
89
|
-
"zap": ">=0.2.9 <1"
|
|
93
|
+
"mocha": "^11.7.5"
|
|
90
94
|
},
|
|
91
95
|
"engines": {
|
|
92
96
|
"node": ">=18.0.0"
|
|
93
97
|
},
|
|
94
|
-
"license": "MIT"
|
|
98
|
+
"license": "MIT",
|
|
99
|
+
"overrides": {
|
|
100
|
+
"mocha": {
|
|
101
|
+
"diff": "8.0.3",
|
|
102
|
+
"serialize-javascript": "7.0.3"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
95
105
|
}
|