Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function StreamParser(maxStanzaSize) {
EventEmitter.call(this)
var self = this
this.parser = new ltx.bestSaxParser()
/* Count traffic for entire life-time */
this.bytesParsed = 0
this.maxStanzaSize = maxStanzaSize
/* Will be reset upon first stanza, but enforce maxStanzaSize until it is parsed */
this.bytesParsedOnStanzaBegin = 0
this.parser.addListener(
'startElement',
function(name, attrs) {
// TODO: refuse anything but
if (!self.element && (name === 'stream:stream')) {
self.emit('streamStart', attrs)
} else {
var child
if (!self.element) {