UNPKG

@softchef/cdk-iot-device-management

Version:

IoT device management is composed of things, thing types, thing groups, jobs, files API services. The constructs can be used independently, that are based on full-managed service to create an API Gateway & Lambda function.

52 lines (51 loc) 1.86 kB
import { __values } from "tslib"; import { escapeAttribute } from "./escape-attribute"; var XmlNode = (function () { function XmlNode(name, children) { if (children === void 0) { children = []; } this.name = name; this.children = children; this.attributes = {}; } XmlNode.prototype.withName = function (name) { this.name = name; return this; }; XmlNode.prototype.addAttribute = function (name, value) { this.attributes[name] = value; return this; }; XmlNode.prototype.addChildNode = function (child) { this.children.push(child); return this; }; XmlNode.prototype.removeAttribute = function (name) { delete this.attributes[name]; return this; }; XmlNode.prototype.toString = function () { var e_1, _a; var hasChildren = Boolean(this.children.length); var xmlText = "<" + this.name; var attributes = this.attributes; try { for (var _b = __values(Object.keys(attributes)), _c = _b.next(); !_c.done; _c = _b.next()) { var attributeName = _c.value; var attribute = attributes[attributeName]; if (typeof attribute !== "undefined" && attribute !== null) { xmlText += " " + attributeName + "=\"" + escapeAttribute("" + attribute) + "\""; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return (xmlText += !hasChildren ? "/>" : ">" + this.children.map(function (c) { return c.toString(); }).join("") + "</" + this.name + ">"); }; return XmlNode; }()); export { XmlNode };