massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / es.string.at-alternative.js
1 'use strict';
2 var $ = require('../internals/export');
3 var uncurryThis = require('../internals/function-uncurry-this');
4 var requireObjectCoercible = require('../internals/require-object-coercible');
5 var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
6 var toString = require('../internals/to-string');
7 var fails = require('../internals/fails');
8
9 var charAt = uncurryThis(''.charAt);
10
11 var FORCED = fails(function () {
12   return '𠮷'.at(0) !== '\uD842';
13 });
14
15 // `String.prototype.at` method
16 // https://github.com/tc39/proposal-relative-indexing-method
17 $({ target: 'String', proto: true, forced: FORCED }, {
18   at: function at(index) {
19     var S = toString(requireObjectCoercible(this));
20     var len = S.length;
21     var relativeIndex = toIntegerOrInfinity(index);
22     var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex;
23     return (k < 0 || k >= len) ? undefined : charAt(S, k);
24   }
25 });