source: trip-planner-front/node_modules/core-js/modules/es.string.substr.js

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

initial commit

  • Property mode set to 100644
File size: 976 bytes
RevLine 
[6a3a178]1'use strict';
2var $ = require('../internals/export');
3var requireObjectCoercible = require('../internals/require-object-coercible');
4var toInteger = require('../internals/to-integer');
5var toString = require('../internals/to-string');
6
7var slice = ''.slice;
8var max = Math.max;
9var min = Math.min;
10
11// `String.prototype.substr` method
12// https://tc39.es/ecma262/#sec-string.prototype.substr
13$({ target: 'String', proto: true }, {
14 substr: function substr(start, length) {
15 var that = toString(requireObjectCoercible(this));
16 var size = that.length;
17 var intStart = toInteger(start);
18 var intLength, intEnd;
19 if (intStart === Infinity) intStart = 0;
20 if (intStart < 0) intStart = max(size + intStart, 0);
21 intLength = length === undefined ? size : toInteger(length);
22 if (intLength <= 0 || intLength === Infinity) return '';
23 intEnd = min(intStart + intLength, size);
24 return intStart >= intEnd ? '' : slice.call(that, intStart, intEnd);
25 }
26});
Note: See TracBrowser for help on using the repository browser.