1 var uncurryThis = require('../internals/function-uncurry-this');
2 var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
3 var toString = require('../internals/to-string');
4 var requireObjectCoercible = require('../internals/require-object-coercible');
6 var charAt = uncurryThis(''.charAt);
7 var charCodeAt = uncurryThis(''.charCodeAt);
8 var stringSlice = uncurryThis(''.slice);
10 var createMethod = function (CONVERT_TO_STRING) {
11 return function ($this, pos) {
12 var S = toString(requireObjectCoercible($this));
13 var position = toIntegerOrInfinity(pos);
16 if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
17 first = charCodeAt(S, position);
18 return first < 0xD800 || first > 0xDBFF || position + 1 === size
19 || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
24 ? stringSlice(S, position, position + 2)
25 : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
30 // `String.prototype.codePointAt` method
31 // https://tc39.es/ecma262/#sec-string.prototype.codepointat
32 codeAt: createMethod(false),
33 // `String.prototype.at` method
34 // https://github.com/mathiasbynens/String.prototype.at
35 charAt: createMethod(true)