Urara-Blog/node_modules/.pnpm-store/v3/files/64/6bdfa677c2c63761ef6b1fb5f0e5c09a978591e56b247d67f53d6a5d9d3ffc9b03299c4a95411e72acd33842537c6c5d88aa66f7cc2e7623335cf7cf070315
2022-08-14 01:14:53 +08:00

20 lines
740 B
Text

'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var IsIntegralNumber = require('./IsIntegralNumber');
var Type = require('./Type');
var callBound = require('call-bind/callBound');
var $slice = callBound('String.prototype.slice');
// https://262.ecma-international.org/12.0/#substring
module.exports = function substring(S, inclusiveStart, exclusiveEnd) {
if (Type(S) !== 'String' || !IsIntegralNumber(inclusiveStart) || (arguments.length > 2 && !IsIntegralNumber(exclusiveEnd))) {
throw new $TypeError('`S` must be a String, and `inclusiveStart` and `exclusiveEnd` must be integers');
}
return $slice(S, inclusiveStart, arguments.length > 2 ? exclusiveEnd : S.length);
};