source: trip-planner-front/node_modules/core-js/modules/esnext.string.code-points.js@ e29cc2e

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

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var createIteratorConstructor = require('../internals/create-iterator-constructor');
4var requireObjectCoercible = require('../internals/require-object-coercible');
5var toString = require('../internals/to-string');
6var InternalStateModule = require('../internals/internal-state');
7var StringMultibyteModule = require('../internals/string-multibyte');
8
9var codeAt = StringMultibyteModule.codeAt;
10var charAt = StringMultibyteModule.charAt;
11var STRING_ITERATOR = 'String Iterator';
12var setInternalState = InternalStateModule.set;
13var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
14
15// TODO: unify with String#@@iterator
16var $StringIterator = createIteratorConstructor(function StringIterator(string) {
17 setInternalState(this, {
18 type: STRING_ITERATOR,
19 string: string,
20 index: 0
21 });
22}, 'String', function next() {
23 var state = getInternalState(this);
24 var string = state.string;
25 var index = state.index;
26 var point;
27 if (index >= string.length) return { value: undefined, done: true };
28 point = charAt(string, index);
29 state.index += point.length;
30 return { value: { codePoint: codeAt(point, 0), position: index }, done: false };
31});
32
33// `String.prototype.codePoints` method
34// https://github.com/tc39/proposal-string-prototype-codepoints
35$({ target: 'String', proto: true }, {
36 codePoints: function codePoints() {
37 return new $StringIterator(toString(requireObjectCoercible(this)));
38 }
39});
Note: See TracBrowser for help on using the repository browser.