UNPKG

@documentica/webdav

Version:
43 lines (42 loc) 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function parseLockDiscovery(nodelist, type) { let res = undefined; let hasOwner = false; Array.prototype.filter.call(nodelist, i => i.nodeType != 3).forEach(i => (i.localName == type) && (hasOwner = true)); if (hasOwner) Array.prototype.filter.call(nodelist, i => i.nodeType != 3).forEach(i => { if (i.localName === type) { Array.prototype.filter.call(i.childNodes, j => j.nodeType != 3).forEach(i2 => { if (i2.localName == "href") { res = i2.textContent; } }); } }); else Array.prototype.filter.call(nodelist, i => i.nodeType != 3).forEach(i => { if (i.childNodes) res = parseLockDiscovery(i.childNodes, type); }); return res; } function fromXML(nodelist) { let res = {}; res.owner = parseLockDiscovery(nodelist, "owner"); res.locktoken = parseLockDiscovery(nodelist, "locktoken"); return res; } exports.fromXML = fromXML; ; function toXML(value, xmlDoc) { console.warn("lockDiscovery cannot be set for request"); return xmlDoc; } exports.toXML = toXML; ; const codec = { fromXML, toXML }; exports.default = codec;