1 | var classof = require('./classof-raw');
|
2 | var regexpExec = require('./regexp-exec');
|
3 |
|
4 |
|
5 |
|
6 | module.exports = function (R, S) {
|
7 | var exec = R.exec;
|
8 | if (typeof exec === 'function') {
|
9 | var result = exec.call(R, S);
|
10 | if (typeof result !== 'object') {
|
11 | throw TypeError('RegExp exec method returned something other than an Object or null');
|
12 | }
|
13 | return result;
|
14 | }
|
15 |
|
16 | if (classof(R) !== 'RegExp') {
|
17 | throw TypeError('RegExp#exec called on incompatible receiver');
|
18 | }
|
19 |
|
20 | return regexpExec.call(R, S);
|
21 | };
|
22 |
|