Typewriter, invicible characters?

Hi! Any ideas on making this function skip characters that aren’t visible? It still needs to write them, but without the time delay.

TextField.prototype.typeWriter = function(str, ms) {
    var me = this;
    var i = 0;
    var itv = setInterval(function () {
        me.text = str.substring(0, i);
        i++;        
        if (i>str.length) {
            clearInterval(itv);
        }
        updateAfterEvent();
    }, ms);
};