• This sounds good to me... I guess if you know how much data you're expecting maximum then you could just preallocate the buffer? That would be a bit faster and more reliable.

    You can even use the ArrayBuffer view

    this.tcpBuffer = new Uint8Array(1024);
    this.tcpLen = 0;
    ...
    /// in handler
            var c = E.toUint8Array(chunk);
            this.tcpBuffer.set(c, this.tcpLen);
            this.tcpLen += c.length;
    /// and when you're sure you are done
    var result = new Uint8Array(this.tcpBuffer.buffer,0,this.­tcpLen); // make result a 'view' of the right length
    this.tcpLen=0; // reset
    
  • I'm getting a datastream from the audio mixer (MIDI data over TCP), so the data never ends. I suppose I could pre-allocate a 1kb buffer and use it as a FIFO, so long as the consumer code keeps pulling data out.

About