code: function transform(str, from, to) {
    let out = '';
    const escaped = '\\' + to;
  
    for (let i = 0; i < str.length; i++) {
      if (str[i] === to) {
        out += escaped;
      } else if (str[i] === from) {
        out += to;
      } else if (str[i] === '\\' && i + 1 < str.length && str[i + 1] === from) {
        out += from;
        i++;
      } else {
        out += str[i];
      }
    }
    return out;
  }
docs: Replace a character in the string provided taking care of the escaped chars.
  @private
  @param  {string} str A string.
  @param  {from} from A character.
  @param  {to} to A character.
  @return {string} A new string with the character replaced.