source: imaps-frontend/node_modules/core-js/modules/es.string.substr.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var uncurryThis = require('../internals/function-uncurry-this');
4var requireObjectCoercible = require('../internals/require-object-coercible');
5var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
6var toString = require('../internals/to-string');
7
8var stringSlice = uncurryThis(''.slice);
9var max = Math.max;
10var min = Math.min;
11
12// eslint-disable-next-line unicorn/prefer-string-slice -- required for testing
13var FORCED = !''.substr || 'ab'.substr(-1) !== 'b';
14
15// `String.prototype.substr` method
16// https://tc39.es/ecma262/#sec-string.prototype.substr
17$({ target: 'String', proto: true, forced: FORCED }, {
18 substr: function substr(start, length) {
19 var that = toString(requireObjectCoercible(this));
20 var size = that.length;
21 var intStart = toIntegerOrInfinity(start);
22 var intLength, intEnd;
23 if (intStart === Infinity) intStart = 0;
24 if (intStart < 0) intStart = max(size + intStart, 0);
25 intLength = length === undefined ? size : toIntegerOrInfinity(length);
26 if (intLength <= 0 || intLength === Infinity) return '';
27 intEnd = min(intStart + intLength, size);
28 return intStart >= intEnd ? '' : stringSlice(that, intStart, intEnd);
29 }
30});
Note: See TracBrowser for help on using the repository browser.