21 lines
463 B
JavaScript
21 lines
463 B
JavaScript
|
|
||
|
var toString = Object.prototype.toString;
|
||
|
|
||
|
function isRegExp (o) {
|
||
|
return 'object' == typeof o
|
||
|
&& '[object RegExp]' == toString.call(o);
|
||
|
}
|
||
|
|
||
|
module.exports = exports = function (regexp) {
|
||
|
if (!isRegExp(regexp)) {
|
||
|
throw new TypeError('Not a RegExp');
|
||
|
}
|
||
|
|
||
|
var flags = [];
|
||
|
if (regexp.global) flags.push('g');
|
||
|
if (regexp.multiline) flags.push('m');
|
||
|
if (regexp.ignoreCase) flags.push('i');
|
||
|
return new RegExp(regexp.source, flags.join(''));
|
||
|
}
|
||
|
|