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:
837 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var isMatchRecord = require('../helpers/records/match-record');
|
---|
| 6 |
|
---|
| 7 | // https://262.ecma-international.org/13.0/#sec-getmatchindexpair
|
---|
| 8 |
|
---|
| 9 | module.exports = function GetMatchIndexPair(S, match) {
|
---|
| 10 | if (typeof S !== 'string') {
|
---|
| 11 | throw new $TypeError('Assertion failed: `S` must be a String');
|
---|
| 12 | }
|
---|
| 13 | if (!isMatchRecord(match)) {
|
---|
| 14 | throw new $TypeError('Assertion failed: `match` must be a Match Record');
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | if (!(match['[[StartIndex]]'] <= S.length)) {
|
---|
| 18 | throw new $TypeError('`match` [[StartIndex]] must be a non-negative integer <= the length of S');
|
---|
| 19 | }
|
---|
| 20 | if (!(match['[[EndIndex]]'] <= S.length)) {
|
---|
| 21 | throw new $TypeError('`match` [[EndIndex]] must be an integer between [[StartIndex]] and the length of S, inclusive');
|
---|
| 22 | }
|
---|
| 23 | return [match['[[StartIndex]]'], match['[[EndIndex]]']];
|
---|
| 24 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.