UNPKG

recime-bot-runtime

Version:

This runtime is intended to run inside a micro-service container with platform specific integration and module interpreter.

35 lines (34 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var xml2js = require("xml2js"); var XML = /** @class */ (function () { function XML() { } XML.ifConvert = function (data) { return new Promise(function (resolve, reject) { if (typeof data === 'object') { return resolve(data); } var match = data.match(/<xml>[\s\S]*?<\/xml>/g); if (match && match.length) { var parser = xml2js.Parser({ trim: true, explicitArray: false }); parser.parseString(data, function (err, result) { if (err) { resolve(err); } else { resolve(result.xml); } }); } else { return resolve(data); } }); }; return XML; }()); exports.XML = XML;