source: trip-planner-front/node_modules/core-js/modules/esnext.string.at-alternative.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 917 bytes
Line 
1// TODO: disabled by default because of the conflict with another proposal
2'use strict';
3var $ = require('../internals/export');
4var requireObjectCoercible = require('../internals/require-object-coercible');
5var toInteger = require('../internals/to-integer');
6var toLength = require('../internals/to-length');
7var toString = require('../internals/to-string');
8var fails = require('../internals/fails');
9
10var FORCED = fails(function () {
11 return '𠮷'.at(0) !== '\uD842';
12});
13
14// `String.prototype.at` method
15// https://github.com/tc39/proposal-relative-indexing-method
16$({ target: 'String', proto: true, forced: FORCED }, {
17 at: function at(index) {
18 var S = toString(requireObjectCoercible(this));
19 var len = toLength(S.length);
20 var relativeIndex = toInteger(index);
21 var k = relativeIndex >= 0 ? relativeIndex : len + relativeIndex;
22 return (k < 0 || k >= len) ? undefined : S.charAt(k);
23 }
24});
Note: See TracBrowser for help on using the repository browser.