mirror of
https://github.com/musix-org/musix-oss
synced 2024-11-10 08:10:18 +00:00
23 lines
598 B
JavaScript
23 lines
598 B
JavaScript
var classof = require('./classof-raw');
|
|
var regexpExec = require('./regexp-exec');
|
|
|
|
// `RegExpExec` abstract operation
|
|
// https://tc39.github.io/ecma262/#sec-regexpexec
|
|
module.exports = function (R, S) {
|
|
var exec = R.exec;
|
|
if (typeof exec === 'function') {
|
|
var result = exec.call(R, S);
|
|
if (typeof result !== 'object') {
|
|
throw TypeError('RegExp exec method returned something other than an Object or null');
|
|
}
|
|
return result;
|
|
}
|
|
|
|
if (classof(R) !== 'RegExp') {
|
|
throw TypeError('RegExp#exec called on incompatible receiver');
|
|
}
|
|
|
|
return regexpExec.call(R, S);
|
|
};
|
|
|