source: trip-planner-front/node_modules/core-js/modules/es.string.iterator.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1'use strict';
2var charAt = require('../internals/string-multibyte').charAt;
3var toString = require('../internals/to-string');
4var InternalStateModule = require('../internals/internal-state');
5var defineIterator = require('../internals/define-iterator');
6
7var STRING_ITERATOR = 'String Iterator';
8var setInternalState = InternalStateModule.set;
9var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
10
11// `String.prototype[@@iterator]` method
12// https://tc39.es/ecma262/#sec-string.prototype-@@iterator
13defineIterator(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});
Note: See TracBrowser for help on using the repository browser.