massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / string-multibyte.js
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');
5
6 var charAt = uncurryThis(''.charAt);
7 var charCodeAt = uncurryThis(''.charCodeAt);
8 var stringSlice = uncurryThis(''.slice);
9
10 var createMethod = function (CONVERT_TO_STRING) {
11   return function ($this, pos) {
12     var S = toString(requireObjectCoercible($this));
13     var position = toIntegerOrInfinity(pos);
14     var size = S.length;
15     var first, second;
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
20         ? CONVERT_TO_STRING
21           ? charAt(S, position)
22           : first
23         : CONVERT_TO_STRING
24           ? stringSlice(S, position, position + 2)
25           : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
26   };
27 };
28
29 module.exports = {
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)
36 };