function replaceStringSelection(replacement, text, range) {
  var end = range.start + range.length;
  return text.substring(0, range.start) + replacement + text.substring(end);
}
Replaces the characters within the selection with given text.

@example
    // 12|34567|8
    replaceStringSelection('12345678', '00', { start: 2, length: 5 });
    // 12|00|8

@param   {string} replacement
@param   {string} text
@param   {object} {start: number, length: number}
@returns {string}