UNPKG

azurite

Version:

An open source Azure Storage API compatible server

44 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.jsonToXML = exports.parseXML = exports.stringifyXML = void 0; const tslib_1 = require("tslib"); const xml2js = tslib_1.__importStar(require("xml2js")); function stringifyXML(obj, opts) { const builder = new xml2js.Builder({ explicitArray: false, explicitCharkey: false, renderOpts: { pretty: false }, rootName: (opts || {}).rootName }); return builder.buildObject(obj); } exports.stringifyXML = stringifyXML; function parseXML(str, explicitChildrenWithOrder = false) { const xmlParser = new xml2js.Parser({ explicitArray: false, explicitCharkey: false, explicitRoot: false, preserveChildrenOrder: explicitChildrenWithOrder, explicitChildren: explicitChildrenWithOrder, emptyTag: undefined }); return new Promise((resolve, reject) => { xmlParser.parseString(str, (err, res) => { if (err) { reject(err); } else { resolve(res); } }); }); } exports.parseXML = parseXML; function jsonToXML(json) { const build = new xml2js.Builder(); return build.buildObject(json); } exports.jsonToXML = jsonToXML; //# sourceMappingURL=xml.js.map