function isSurrogatePair(str, index) {
  invariant(
    0 <= index && index < str.length,
    'isSurrogatePair: Invalid index %s for string length %s.',
    index,
    str.length
  );
  if (index + 1 === str.length) {
    return false;
  }
  const first = str.charCodeAt(index);
  const second = str.charCodeAt(index + 1);
  return (
    SURROGATE_HIGH_START <= first && first <= SURROGATE_HIGH_END &&
    SURROGATE_LOW_START <= second && second <= SURROGATE_LOW_END
  );
}
Returns whether the two characters starting at `index` form a surrogate pair.
For example, given the string s = "\uD83D\uDE0A", (s, 0) returns true and
(s, 1) returns false.

@param {string} str
@param {number} index
@return {boolean}