.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / esnext.string.code-points.js
1 'use strict';
2 var $ = require('../internals/export');
3 var createIteratorConstructor = require('../internals/create-iterator-constructor');
4 var requireObjectCoercible = require('../internals/require-object-coercible');
5 var InternalStateModule = require('../internals/internal-state');
6 var StringMultibyteModule = require('../internals/string-multibyte');
7
8 var codeAt = StringMultibyteModule.codeAt;
9 var charAt = StringMultibyteModule.charAt;
10 var STRING_ITERATOR = 'String Iterator';
11 var setInternalState = InternalStateModule.set;
12 var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
13
14 // TODO: unify with String#@@iterator
15 var $StringIterator = createIteratorConstructor(function StringIterator(string) {
16   setInternalState(this, {
17     type: STRING_ITERATOR,
18     string: string,
19     index: 0
20   });
21 }, 'String', 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: { codePoint: codeAt(point, 0), position: index }, done: false };
30 });
31
32 // `String.prototype.codePoints` method
33 // https://github.com/tc39/proposal-string-prototype-codepoints
34 $({ target: 'String', proto: true }, {
35   codePoints: function codePoints() {
36     return new $StringIterator(String(requireObjectCoercible(this)));
37   }
38 });