@loaders.gl/xml 4.2.0-alpha.4 → 4.2.0-alpha.6
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/dist/dist.dev.js +209 -154
- package/dist/dist.min.js +23 -0
- package/dist/html-loader.d.ts +1 -1
- package/dist/html-loader.d.ts.map +1 -1
- package/dist/html-loader.js +31 -20
- package/dist/index.cjs +157 -140
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/lib/parsers/parse-xml.d.ts +1 -1
- package/dist/lib/parsers/parse-xml.d.ts.map +1 -1
- package/dist/lib/parsers/parse-xml.js +48 -34
- package/dist/lib/parsers/streaming-xml-parser.d.ts +1 -1
- package/dist/lib/parsers/streaming-xml-parser.d.ts.map +1 -1
- package/dist/lib/parsers/streaming-xml-parser.js +94 -101
- package/dist/lib/xml-utils/uncapitalize.js +24 -12
- package/dist/lib/xml-utils/xml-utils.js +24 -10
- package/dist/sax-ts/sax.js +1396 -1235
- package/dist/xml-loader.d.ts +1 -1
- package/dist/xml-loader.d.ts.map +1 -1
- package/dist/xml-loader.js +33 -28
- package/package.json +10 -7
- package/dist/html-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/parsers/parse-xml.js.map +0 -1
- package/dist/lib/parsers/streaming-xml-parser.js.map +0 -1
- package/dist/lib/xml-utils/uncapitalize.js.map +0 -1
- package/dist/lib/xml-utils/xml-utils.js.map +0 -1
- package/dist/sax-ts/sax.js.map +0 -1
- package/dist/xml-loader.js.map +0 -1
|
@@ -1,14 +1,28 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// TODO - these utilities could be moved to the XML parser.
|
|
5
|
+
// uncapitalizeKeys could be an XMLLoader option
|
|
6
|
+
/**
|
|
7
|
+
* Extracts a value or array and always return an array
|
|
8
|
+
* Useful since XML parses to object instead of array when only a single value is provided
|
|
9
|
+
*/
|
|
1
10
|
export function convertXMLValueToArray(xmlValue) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
if (Array.isArray(xmlValue)) {
|
|
12
|
+
return xmlValue;
|
|
13
|
+
}
|
|
14
|
+
if (xmlValue && typeof xmlValue === 'object' && xmlValue['0']) {
|
|
15
|
+
// Error this is an objectified array
|
|
16
|
+
}
|
|
17
|
+
if (xmlValue) {
|
|
18
|
+
return [xmlValue];
|
|
19
|
+
}
|
|
20
|
+
return [];
|
|
10
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Mutates a field in place, converting it to array
|
|
24
|
+
* Useful since XML parses to object instead of array when only a single value is provided
|
|
25
|
+
*/
|
|
11
26
|
export function convertXMLFieldToArrayInPlace(xml, key) {
|
|
12
|
-
|
|
27
|
+
xml[key] = convertXMLValueToArray(xml[key]);
|
|
13
28
|
}
|
|
14
|
-
//# sourceMappingURL=xml-utils.js.map
|