source/lib/VBConnPanel.js
// elements for the output data is astonishingly faster

elements for the output data is astonishingly faster
elements for the output data is astonishingly faster
appendPacket(packet) {
    this.vbLog.write(packet)
    const ma = packet.match(/\n/g)
    const lineCount = ma ? ma.length : 0
    this.outputLineCount += lineCount
    const disp = this.connPage.style.display
    this.connPage.style.display = 'none'
    if (this.config.autoScroll) {
      while (this.outputLineCount > this.config.maxOutputNodes) {
        let linesInPacket = this.linesPerPacket.shift()
        if (this.deviceOutputPanel.firstChild) {
          this.deviceOutputPanel.removeChild(this.deviceOutputPanel.firstChild)
        }
        this.outputLineCount -= linesInPacket
      }
    }
    if (this.lastOutputChar !== '\n' && this.lastDOMTextNode) {
      this.lastDOMTextContent += packet
      this.lastDOMTextNode.nodeValue = this.lastDOMTextContent
      const prevPacketLines = this.linesPerPacket.pop()
      this.linesPerPacket.push(prevPacketLines + lineCount)
    }
    else {
      const tr = document.createElement('TR')
      const td = document.createElement('TD')
      const pre = document.createElement('PRE')
      this.lastDOMTextContent = packet.slice(0)
      this.lastDOMTextNode = document.createTextNode(packet)
      pre.appendChild(this.lastDOMTextNode)
      td.appendChild(pre)
      tr.appendChild(td)
      this.deviceOutputPanel.appendChild(tr)
      this.linesPerPacket.push(lineCount)
    }
    this.lastOutputChar = packet.slice(-1)
    this.connPage.style.display = disp
    this.doScrollToEnd()
  }
appendPacket ( packet ) { this . vbLog . write ( packet ) const ma = packet . match ( / \n / g ) const lineCount = ma ? ma . length : 0 this . outputLineCount += lineCount const disp = this . connPage . style . display this . connPage . style . display = 'none' if ( this . config . autoScroll ) { while ( this . outputLineCount > this . config . maxOutputNodes ) { let linesInPacket = this . linesPerPacket . shift ( ) if ( this . deviceOutputPanel . firstChild ) { this . deviceOutputPanel . removeChild ( this . deviceOutputPanel . firstChild ) } this . outputLineCount -= linesInPacket } } if ( this . lastOutputChar !== '\n' && this . lastDOMTextNode ) { this . lastDOMTextContent += packet this . lastDOMTextNode . nodeValue = this . lastDOMTextContent const prevPacketLines = this . linesPerPacket . pop ( ) this . linesPerPacket . push ( prevPacketLines + lineCount ) } else { const tr = document . createElement ( 'TR' ) const td = document . createElement ( 'TD' ) const pre = document . createElement ( 'PRE' ) this . lastDOMTextContent = packet . slice ( 0 ) this . lastDOMTextNode = document . createTextNode ( packet ) pre . appendChild ( this . lastDOMTextNode ) td . appendChild ( pre ) tr . appendChild ( td ) this . deviceOutputPanel . appendChild ( tr ) this . linesPerPacket . push ( lineCount ) } this . lastOutputChar = packet . slice ( - 1 ) this . connPage . style . display = disp this . doScrollToEnd ( ) }
elements for the output data is astonishingly faster
elements for the output data is astonishingly faster
// Log the data
 // Count number of \n characters in this data packet
 // Keep track of how many total lines we have
 // Chrome renderng optimization - update display while hidden
 // Remove packets until line count does not exceed our limit,
 // but only if autoScroll is set, otherwise if the user has turned off
 // autoScroll and paged back to look at a particular area, then the
 // display may jump around as earlier data is pruned
 // If the previously-written output line was not \n-terminated,
 // then append this packet to the previous <tr>,
 // otherwise create a new <tr> for the packet
 // Add the new packet to the output pane
