Quickly passing and parsing variable length float arrays I have this code for parsing for parsing a list of floats of variable length.

on_message = function(event_data) {
    var data = event_data.split(" ").map(parseFloat)
    var size = data.shift() + 1;
    while (data.length &gt;= size) {
        // put the data in a buffer
        // could be replace by console.log() for testing purposes
        // each data chunk needs to be pushed separately
        this.data_store.push(data.slice(0, size));
        data = data.slice(size);
        size = data.shift() + 1;
    }
    // start displaying stuff to the user ASAP
    this.schedule_update();
}


At this point, the data is formatted in the following manner when a single "chunk" is sent:

[length data_1 data_2 etc etc]


However, because the back-end that sends these updates can sometimes be faster than the front-end, multiple "chunks" can be sent at the same:

[length_1 data_1_1 data_1_2 etc_1 etc_1 length_2 data_2_1 data_2_2 etc_2]


As mentioned before, all values in event_data are floats, except for the length which is an int.

The format of the data packet is not set, although the fact that more than one "chunk" can be sent at a time and the chunks are different sizes cannot be changed. I would just like to be able to send a variable length array of floats to a buffer quickly and efficiently. Right now, this code is taking really long. What can I do to speed it up?
You can get some improvements by using JSON and moving the length increment to the back-end like so:

Nengo.SpaSimilarity.prototype.on_message = function(event) {
    var data = JSON.parse(event.data);
    var size = data.shift();
    while (data.length &gt;= size) {
        this.data_store.push(data.slice(0, size));
        data = data.slice(size);
        size = data.shift();
    }
    this.schedule_update();
}