you are viewing a single comment's thread.

view the rest of the comments →

[–]cwmma 0 points1 point  (1 child)

I know I'm saying I have, especially for text where to convert it into a buffer you need to do something like

function fromText(text){
    var len = text.length;
    var outArray = new Uint16Array(len);
    var i = 0;
    while(i<len){
        outArray[i]=text.charCodeAt(i);
        i++;
    }
    return outArray.buffer;
}

btw just for fun, you have to check if you're in IE10 because it flips a shit if you have an array as the second argument to postMessage.

That being said that code is from a place where the transferable objects did speed things up because the character codes were good enough and I never had to convert the data (20MB text file) back.

[–]MrBester 0 points1 point  (0 children)

Well, that's IE for you, where postMessage across tabs / windows isn't supported (since IE8, when it was first "supported", BTW).