Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beautify(frag) {
let el
if (typeof frag === 'string') {
try {
el = xml.parse(frag)
} catch (err) {
return frag
}
} else {
el = frag
}
return xml.stringify(el, ' ')
}
parse(str) {
try {
return xml.parse(str)
} catch (err) {
return str
}
}
send(data) {
let el
try {
el = xml.parse(data)
} catch (err) {
this.error(`invalid XML "${data}"`)
return
}
this.entity.send(el).then(() => {
this.resetInput()
})
}