@remote.it/core
Version:
Core remote.it JavasScript/TypeScript library
55 lines • 1.96 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var xml_js_1 = __importDefault(require("xml-js"));
var debug_1 = __importDefault(require("debug"));
var File_1 = require("./File");
var d = debug_1.default('remoteit:XMLFile');
var XMLFile = /** @class */ (function (_super) {
__extends(XMLFile, _super);
function XMLFile(location) {
var _this = _super.call(this, location) || this;
_this.location = location;
_this.baseOptions = {
attributesKey: 'attributes',
compact: true,
nativeType: true,
spaces: 2,
textKey: 'text',
};
return _this;
}
/**
* Return the JavaScript object representation of the
* XML file.
*/
XMLFile.prototype.read = function () {
return xml_js_1.default.xml2js(this.content, this.baseOptions);
};
/**
* Write the contents as XML to the file.
*/
XMLFile.prototype.write = function (content) {
var xml = xml_js_1.default.js2xml(content, this.baseOptions);
this.content = xml;
d('wrote:', xml);
};
return XMLFile;
}(File_1.File));
exports.XMLFile = XMLFile;
//# sourceMappingURL=XMLFile.js.map