lib/replace.js
function applyReplacements(str, replacements) {
    var result = "",
        replacement,
        i;

    for (i = 0; i < replacements.length; i++) {
        replacement = replacements[i];
        if (replacement) {
            result += replacement.newStr;
            i += replacement.oldStr.length - 1;
        } else {
            result += str.charAt(i);
        }
    }

    result += str.substr(i, str.length);

    return result;
}
function applyReplacements(str, replacements) {
    var result = "",
        replacement,
        i;

    for (i = 0; i < replacements.length; i++) {
        replacement = replacements[i];
        if (replacement) {
            result += replacement.newStr;
            i += replacement.oldStr.length - 1;
        } else {
            result += str.charAt(i);
        }
    }

    result += str.substr(i, str.length);

    return result;
}
function applyReplacements ( str , replacements ) { var result = "" , replacement , i ; for ( i = 0 ; i < replacements . length ; i ++ ) { replacement = replacements [ i ] ; if ( replacement ) { result += replacement . newStr ; i += replacement . oldStr . length - 1 ; } else { result += str . charAt ( i ) ; } } result += str . substr ( i , str . length ) ; return result ; }
Applies all replacements on the given string.

@private
@param {String} str
@param {Array<Replacement>} replacements
@returns {string}
Applies all replacements on the given string .