code: function safer(regex, exception) {
  
    var e = exception === undefined ? true : Boolean(exception);
    var output;
    if (e) {
      output = function(err) {
  
        if (err) {
          throw new Error(err);
        }
      };
    } else {
      output = function(err) {
  
        return Boolean(!err);
      };
    }
  
    if (!regex || typeof regex !== 'string') { // string validation
      return output('argument must be a string');
    }
  
    try { // regex validation
      var _ = new RegExp(regex);
    } catch (err) {
      return output(err);
    }
  
    if (safe(regex) === false) {
      return output('regex is invalid or not safe');
    }
    return output();
  }
docs: option setting
  
  @exports safer
  @function safer
  @param {String} regex - check this string regex
  @param {Boolean} [exception] - raise an exception if true