|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
830 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var $TypeError = require('es-errors/type');
|
|---|
| 4 | var isObject = require('es-object-atoms/isObject');
|
|---|
| 5 | var regexExec = require('call-bound')('RegExp.prototype.exec');
|
|---|
| 6 |
|
|---|
| 7 | var Call = require('./Call');
|
|---|
| 8 | var Get = require('./Get');
|
|---|
| 9 | var IsCallable = require('./IsCallable');
|
|---|
| 10 |
|
|---|
| 11 | // https://262.ecma-international.org/6.0/#sec-regexpexec
|
|---|
| 12 |
|
|---|
| 13 | module.exports = function RegExpExec(R, S) {
|
|---|
| 14 | if (!isObject(R)) {
|
|---|
| 15 | throw new $TypeError('Assertion failed: `R` must be an Object');
|
|---|
| 16 | }
|
|---|
| 17 | if (typeof S !== 'string') {
|
|---|
| 18 | throw new $TypeError('Assertion failed: `S` must be a String');
|
|---|
| 19 | }
|
|---|
| 20 | var exec = Get(R, 'exec');
|
|---|
| 21 | if (IsCallable(exec)) {
|
|---|
| 22 | var result = Call(exec, R, [S]);
|
|---|
| 23 | if (result === null || isObject(result)) {
|
|---|
| 24 | return result;
|
|---|
| 25 | }
|
|---|
| 26 | throw new $TypeError('"exec" method must return `null` or an Object');
|
|---|
| 27 | }
|
|---|
| 28 | return regexExec(R, S);
|
|---|
| 29 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.