deps/v8/src/js/string-iterator.js
function StringIteratorNext() {
  var iterator = this;
  var value = UNDEFINED;
  var done = true;

  if (!IS_RECEIVER(iterator) ||
      !HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
    throw MakeTypeError(kIncompatibleMethodReceiver,
                        'String Iterator.prototype.next');
  }

  var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol);
  if (!IS_UNDEFINED(s)) {
    var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol);
    var length = TO_UINT32(s.length);
    if (position >= length) {
      SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, UNDEFINED);
    } else {
      var first = %_StringCharCodeAt(s, position);
      value = %_StringCharFromCode(first);
      done = false;
      position++;

      if (first >= 0xD800 && first <= 0xDBFF && position < length) {
        var second = %_StringCharCodeAt(s, position);
        if (second >= 0xDC00 && second <= 0xDFFF) {
          value += %_StringCharFromCode(second);
          position++;
        }
      }

      SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, position);
    }
  }
  return %_CreateIterResultObject(value, done);
}
function StringIteratorNext() {
  var iterator = this;
  var value = UNDEFINED;
  var done = true;

  if (!IS_RECEIVER(iterator) ||
      !HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
    throw MakeTypeError(kIncompatibleMethodReceiver,
                        'String Iterator.prototype.next');
  }

  var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol);
  if (!IS_UNDEFINED(s)) {
    var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol);
    var length = TO_UINT32(s.length);
    if (position >= length) {
      SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, UNDEFINED);
    } else {
      var first = %_StringCharCodeAt(s, position);
      value = %_StringCharFromCode(first);
      done = false;
      position++;

      if (first >= 0xD800 && first <= 0xDBFF && position < length) {
        var second = %_StringCharCodeAt(s, position);
        if (second >= 0xDC00 && second <= 0xDFFF) {
          value += %_StringCharFromCode(second);
          position++;
        }
      }

      SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, position);
    }
  }
  return %_CreateIterResultObject(value, done);
}
ES6 section 21.1.5.2.1 %StringIteratorPrototype%.next ( )