@tak-ps/node-cot
Version:
Lightweight JavaScript library for parsing and manipulating TAK messages
23 lines • 674 B
JavaScript
import Err from '@openaddresses/batch-error';
import xmljs from 'xml-js';
/**
* Core XML Document support used for XML fortatted DataPackages documents
* such as Iconsets or Basemaps
*/
export default class XMLDocument {
raw;
constructor(raw) {
this.raw = raw;
}
static check(input, check) {
const xml = xmljs.xml2js(input, { compact: true });
check(xml);
if (check.errors)
throw new Err(400, null, `${check.errors[0].message} (${check.errors[0].instancePath})`);
return xml;
}
to_xml() {
return xmljs.js2xml(this.raw, { compact: true });
}
}
//# sourceMappingURL=xml-document.js.map