1'use strict'; 2 3var classof = require('./_classof'); 4var builtinExec = RegExp.prototype.exec; 5 6 // `RegExpExec` abstract operation 7// https://tc39.github.io/ecma262/#sec-regexpexec 8module.exports = function (R, S) { 9 var exec = R.exec; 10 if (typeof exec === 'function') { 11 var result = exec.call(R, S); 12 if (typeof result !== 'object') { 13 throw new TypeError('RegExp exec method returned something other than an Object or null'); 14 } 15 return result; 16 } 17 if (classof(R) !== 'RegExp') { 18 throw new TypeError('RegExp#exec called on incompatible receiver'); 19 } 20 return builtinExec.call(R, S); 21}; 22