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
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var isInteger = require('../helpers/isInteger');
|
---|
| 6 |
|
---|
| 7 | var callBound = require('call-bind/callBound');
|
---|
| 8 |
|
---|
| 9 | var $slice = callBound('String.prototype.slice');
|
---|
| 10 |
|
---|
| 11 | // https://262.ecma-international.org/12.0/#substring
|
---|
| 12 | module.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.