apis/fs/index.js
// Check if the path matches one of the given files
Check if the path matches one of the given files
Check if the path matches one of the given files
function _matchDeclaredFile(path, files) {
  var declared_file_names = Object.keys(files);
  for (var f = 0; f < declared_file_names.length; f++) {
    var possibility = declared_file_names[f];
    if (path === possibility) {
      return possibility;
    }
    var stripped_path = (FILE_REGEX.test(path) ? FILE_REGEX.exec(path)[1] : path);
    var stripped_possibility = (FILE_REGEX.test(possibility) ? FILE_REGEX.exec(possibility)[1] : possibility);
    if (stripped_path === stripped_possibility ||
      stripped_path + '.js' === stripped_possibility ||
      stripped_path + '.JS' === stripped_possibility) {
      return possibility;
    }
  }
  return null;
}
function _matchDeclaredFile ( path , files ) { var declared_file_names = Object . keys ( files ) ; for ( var f = 0 ; f < declared_file_names . length ; f ++ ) { var possibility = declared_file_names [ f ] ; if ( path === possibility ) { return possibility ; } var stripped_path = ( FILE_REGEX . test ( path ) ? FILE_REGEX . exec ( path ) [ 1 ] : path ) ; var stripped_possibility = ( FILE_REGEX . test ( possibility ) ? FILE_REGEX . exec ( possibility ) [ 1 ] : possibility ) ; if ( stripped_path === stripped_possibility || stripped_path + '.js' === stripped_possibility || stripped_path + '.JS' === stripped_possibility ) { return possibility ; } } return null ; }
Check if the path matches one of the given files
Check if the path matches one of the given files
// Check if the path matches the possibility when the "./" and "/" prefix are stripped away // Note that ".js" files can be required without the extension so we need // to check if appending ".js" makes the path match the possibility