1 | 'use strict';
|
2 | var call = require('../internals/function-call');
|
3 | var anObject = require('../internals/an-object');
|
4 | var isCallable = require('../internals/is-callable');
|
5 | var classof = require('../internals/classof-raw');
|
6 | var regexpExec = require('../internals/regexp-exec');
|
7 |
|
8 | var $TypeError = TypeError;
|
9 |
|
10 |
|
11 |
|
12 | module.exports = function (R, S) {
|
13 | var exec = R.exec;
|
14 | if (isCallable(exec)) {
|
15 | var result = call(exec, R, S);
|
16 | if (result !== null) anObject(result);
|
17 | return result;
|
18 | }
|
19 | if (classof(R) === 'RegExp') return call(regexpExec, R, S);
|
20 | throw new $TypeError('RegExp#exec called on incompatible receiver');
|
21 | };
|