function shimTrimRight(string, chars) {
    string = string == null ? '' : String(string);
    if (!string) {
      return string;
    }
    if (chars == null) {
      return string.slice(0, trimmedRightIndex(string) + 1)
    }
    chars = String(chars);
    return string.slice(0, charsRightIndex(string, chars) + 1);
  }
A fallback implementation of `trimRight` to remove trailing whitespace or
specified characters from `string`.

@private
@param {string} string The string to trim.
@param {string} [chars=whitespace] The characters to trim.
@returns {string} Returns the trimmed string.