massive update, probably broken
[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 toString = require('../internals/to-string');
6 var InternalStateModule = require('../internals/internal-state');
7 var StringMultibyteModule = require('../internals/string-multibyte');
8
9 var codeAt = StringMultibyteModule.codeAt;
10 var charAt = StringMultibyteModule.charAt;
11 var STRING_ITERATOR = 'String Iterator';
12 var setInternalState = InternalStateModule.set;
13 var getInternalState = InternalStateModule.getterFor(STRING_ITERATOR);
14
15 // TODO: unify with String#@@iterator
16 var $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 });