source: imaps-frontend/node_modules/es-abstract/2023/substring.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 644 bytes
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var isInteger = require('../helpers/isInteger');
6
7var callBound = require('call-bind/callBound');
8
9var $slice = callBound('String.prototype.slice');
10
11// https://262.ecma-international.org/12.0/#substring
12module.exports = function substring(S, inclusiveStart, exclusiveEnd) {
13 if (typeof S !== 'string' || !isInteger(inclusiveStart) || (arguments.length > 2 && !isInteger(exclusiveEnd))) {
14 throw new $TypeError('`S` must be a String, and `inclusiveStart` and `exclusiveEnd` must be integers');
15 }
16 return $slice(S, inclusiveStart, arguments.length > 2 ? exclusiveEnd : S.length);
17};
Note: See TracBrowser for help on using the repository browser.