1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | exports.fixExistingDollarSign = exports.JsonAsXml = exports.writeJSONasXML = exports.standardOptions = void 0;
|
10 | const fs_1 = require("fs");
|
11 | const jsToXml = require("js2xmlparser");
|
12 | exports.standardOptions = {
|
13 | declaration: {
|
14 | include: true,
|
15 | encoding: 'UTF-8',
|
16 | version: '1.0',
|
17 | },
|
18 | format: {
|
19 | doubleQuotes: true,
|
20 | },
|
21 | };
|
22 | const writeJSONasXML = async ({ path, json, type, options = exports.standardOptions, }) => {
|
23 | const xml = jsToXml.parse(type, exports.fixExistingDollarSign(json), options);
|
24 | return await fs_1.promises.writeFile(path, xml);
|
25 | };
|
26 | exports.writeJSONasXML = writeJSONasXML;
|
27 | const JsonAsXml = ({ json, type, options = exports.standardOptions }) => {
|
28 | return jsToXml.parse(type, exports.fixExistingDollarSign(json), options);
|
29 | };
|
30 | exports.JsonAsXml = JsonAsXml;
|
31 | const fixExistingDollarSign = (existing) => {
|
32 | const existingCopy = { ...existing };
|
33 | if (existingCopy.$) {
|
34 | const temp = existingCopy.$;
|
35 | delete existingCopy.$;
|
36 | existingCopy['@'] = temp;
|
37 | }
|
38 | return existingCopy;
|
39 | };
|
40 | exports.fixExistingDollarSign = fixExistingDollarSign;
|
41 |
|
\ | No newline at end of file |