register.js
function regexpPattern(pattern) {
  if (!pattern) {
    return pattern;
  }
  // A very simplified glob transform which allows passing legible strings like
  // "myPath/*.js" instead of a harder to read RegExp like /\/myPath\/.*\.js/.
  if (typeof pattern === 'string') {
    pattern = pattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
    if (pattern[0] !== '/') {
      pattern = '/' + pattern;
    }
    return new RegExp(pattern);
  }
  if (typeof pattern.test === 'function') {
    return pattern;
  }
  throw new Error(
    'flow-remove-types: includes and excludes must be RegExp or path strings. Got: ' + pattern
  );
}
function regexpPattern(pattern) {
  if (!pattern) {
    return pattern;
  }
  // A very simplified glob transform which allows passing legible strings like
  // "myPath/*.js" instead of a harder to read RegExp like /\/myPath\/.*\.js/.
  if (typeof pattern === 'string') {
    pattern = pattern.replace(/\./g, '\\.').replace(/\*/g, '.*');
    if (pattern[0] !== '/') {
      pattern = '/' + pattern;
    }
    return new RegExp(pattern);
  }
  if (typeof pattern.test === 'function') {
    return pattern;
  }
  throw new Error(
    'flow-remove-types: includes and excludes must be RegExp or path strings. Got: ' + pattern
  );
}
function regexpPattern ( pattern ) { if ( ! pattern ) { return pattern ; } // A very simplified glob transform which allows passing legible strings like // "myPath/*.js" instead of a harder to read RegExp like /\/myPath\/.*\.js/. if ( typeof pattern === 'string' ) { pattern = pattern . replace ( / \. / g , '\\.' ) . replace ( / \* / g , '.*' ) ; if ( pattern [ 0 ] !== '/' ) { pattern = '/' + pattern ; } return new RegExp ( pattern ) ; } if ( typeof pattern . test === 'function' ) { return pattern ; } throw new Error ( 'flow-remove-types: includes and excludes must be RegExp or path strings. Got: ' + pattern ) ; }
Given a null | string | RegExp | any, returns null | Regexp or throws a more helpful error.
Given a null | string | RegExp | any returns null | Regexp or throws a more helpful error .