@hazae41/kdbx
Version:
Rust-like KeePass (KDBX 4) file format for TypeScript
21 lines (20 loc) • 644 B
JavaScript
// deno-lint-ignore-file no-namespace
export var XML;
(function (XML) {
function format(node, tab = " ") {
const text = new XMLSerializer().serializeToString(node);
let result = "";
let indent = 0;
const nodes = text.split(/>\s*</);
for (const node of nodes) {
if (node.match(/^\/\w/))
indent--;
result += tab.repeat(indent) + '<' + node + '>\r\n';
if (node.match(/^<?\w[^>]*[^\/]$/))
indent++;
continue;
}
return result.slice(1, result.length - 3);
}
XML.format = format;
})(XML || (XML = {}));