massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / es.string.iterator.js
1 'use strict';
2 var charAt = require('../internals/string-multibyte').charAt;
3 var toString = require('../internals/to-string');
4 var InternalStateModule = require('../internals/internal-state');
5 var defineIterator = require('../internals/define-iterator');
6
7 var STRING_ITERATOR = 'String Iterator';
8 var setInternalState = InternalStateModule.set;
9 var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
10
11 // `String.prototype[@@iterator]` method
12 // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
13 defineIterator(String, 'String', function (iterated) {
14   setInternalState(this, {
15     type: STRING_ITERATOR,
16     string: toString(iterated),
17     index: 0
18   });
19 // `%StringIteratorPrototype%.next` method
20 // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
21 }, function next() {
22   var state = getInternalState(this);
23   var string = state.string;
24   var index = state.index;
25   var point;
26   if (index >= string.length) return { value: undefined, done: true };
27   point = charAt(string, index);
28   state.index += point.length;
29   return { value: point, done: false };
30 });