Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / esnext.string.at-alternative.js
1 // TODO: disabled by default because of the conflict with another proposal
2 'use strict';
3 var $ = require('../internals/export');
4 var requireObjectCoercible = require('../internals/require-object-coercible');
5 var toLength = require('../internals/to-length');
6 var toInteger = require('../internals/to-integer');
7 var fails = require('../internals/fails');
8
9 var FORCED = fails(function () {
10   return '𠮷'.at(0) !== '\uD842';
11 });
12
13 // `String.prototype.at` method
14 // https://github.com/tc39/proposal-relative-indexing-method
15 $({ target: 'String', proto: true, forced: FORCED }, {
16   at: function at(index) {
17     var S = String(requireObjectCoercible(this));
18     var len = toLength(S.length);
19     var relativeIndex = toInteger(index);
20     var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex;
21     return (k < 0 || k >= len) ? undefined : S.charAt(k);
22   }
23 });