index.js
function getRegex(regex, flags) {
  var result = typeOf(regex) === 'String'
    ? new RegExp(regex, flags || '')
    : regex

  if (typeOf(result) !== 'RegExp') {
    throw new Error(
      NAME + ': option "regex" must be a string or a RegExp object')
  }

  return result
}
function getRegex(regex, flags) {
  var result = typeOf(regex) === 'String'
    ? new RegExp(regex, flags || '')
    : regex

  if (typeOf(result) !== 'RegExp') {
    throw new Error(
      NAME + ': option "regex" must be a string or a RegExp object')
  }

  return result
}
function getRegex ( regex , flags ) { var result = typeOf ( regex ) === 'String' ? new RegExp ( regex , flags || '' ) : regex if ( typeOf ( result ) !== 'RegExp' ) { throw new Error ( NAME + ': option "regex" must be a string or a RegExp object' ) } return result }
Transform regex into a RegExp if it isn't one already.

@param {any} regex
@param {string} flags
@returns {RegExp}
Transform regex into a RegExp if it isn t one already .