filter files array
@param  {Array} files
@param  {String|RegExp|Function} check
@return {Array}
435238
function filterFiles(files, check) {
	return files.filter(function(file) {
		if (typeof check == 'string') {
			// ignore typecase equal
			return check.toLowerCase() === file.toLowerCase();
		} else if (Util.isRegExp(check)) {
			// regexp test
			return check.test(file);
		} else if (typeof check == 'function') {
			// function callback
			return check(file);
		}
	});
}
1352897
function filterFile(file, callback) {
      // Ensure it matches the extension.
      const correctExtention = path.extname(file) === opts.extname

      // Make sure it has defined files.
      const source = files[file].source || false
      const destination = files[file].destination || '.'
      callback(null, correctExtention && source && destination)
    }
924124
function findExcess(dir, shrinkwrap, opts, scope, cb) {  // jshint ignore:line
    fs.readdir(dir, function (err, files) {
        if (err) {
            return cb(err);
        }

        parallel(files.map(function (file) {
            return validateExcess.bind(null, dir, file, shrinkwrap, opts,
              scope);
        }), function (err, excessFiles) {
            if (err) {
                return cb(err);
            }
            return cb(null, flatten(excessFiles || []).filter(Boolean));
        });
    });
}
950759
function filter(fp, opts) {
  if (opts && opts.filter) {
    return opts.filter(fp, opts);
  }
  return /[^x]\.js$/.test(fp);
}
89747
function excludeFiles(list, regex) {
        var ret = [];
        for (var i=0; i < list.length; i++) {
            if (!regex.test(list[i].dst)) {
                ret.push(list[i]);
            }
        }
        return ret;
    }
283859
function filterPaths(paths, allowed) {
  if (!allowed) { return []; }
  if (!allowed.only.length) { return paths; }

  return paths.filter(
    path => {
      let match = false;

      for (const filter of allowed.only) {
        try {
          switch (typeof filter) {
            case 'function':
              match = filter(path.path);
              break;
            case 'string':
              match = path.path === filter;
              break;
            default:
              match = filter.test(path.path);
         }
        } catch (e) {
          throw new Error(`${ typeof filter } is not an allowed filter type. Must be String, RegExp or Function`);
        }
        if (match) { return match; }
      }
      return match;
    }
  );
}
1305602
function matches_filter(filters, logicalPath, filename) {
  if (filters.length === 0) {
    return true;
  }

  return _.some(filters, function (filter) {
    if (_.isRegExp(filter)) {
      return filter.test(logicalPath);
    }

    if (_.isFunction(filter)) {
      return filter(logicalPath, filename);
    }

    // prepare string to become RegExp.
    // mimics shell's globbing
    filter = filter.toString().replace(/\*\*|\*|\?|\\.|\./g, function (m) {
      if (m[0] === '*') {
        return m === '**' ? '.+?' : '[^/]+?';
      }

      if (m[0] === '?') {
        return '[^/]?';
      }

      if (m[0] === '.') {
        return '\\.';
      }

      // handle `\\.` part
      return m;
    });

    // prepare RegExp
    filter = new RegExp('^' + filter + '$');
    return filter.test(logicalPath);
  });
}
1337045
protected function filterFiles($files)
    {
        foreach ($files as $key => $file) {
            if ($file instanceof UploadedFile) {
                continue;
            }

            if (is_array($file)) {
                if (! isset($file['name'])) {
                    $files[$key] = $this->filterFiles($files[$key]);
                } elseif (isset($files[$key]['error']) && $files[$key]['error'] !== 0) {
                    unset($files[$key]);
                }

                continue;
            }

            unset($files[$key]);
        }

        return $files;
    }
58722
function (file) {
  var regex = new RegExp(/(\/\*\! \@\{target\:\s*?).*?([^"]*?)(\} \*\/)/gi),
      replaceRegex = '',
      matches = '',
      match = '',
      parts = '',
      replace = '',
      endString = '',
      files = {},
      cut = '',
      start = 0,
      end = 0,
      result = {};

  matches = file.match(regex);

  for (var i in matches) {
    match = matches[i];
    regex = new RegExp(/(\/\*\! \@\{target\:\s*?).*?([^"]*?)(\} \*\/)/gi)

    parts = regex.exec(match);
    endString = '/*! {target:' + parts[2] + '}@ */'

    start = file.indexOf(parts[0]);
    end = file.indexOf(endString) + endString.length;

    cut = file.slice(start, end);
    file = file.slice(0, start - 1) + file.slice(end + 1);

    cut = cut.replace(parts[0], '').replace(endString, '');

    if (files[parts[2]]) {
      files[parts[2]].push(cut);
    }
    else {
      files[parts[2]] = [];
      files[parts[2]].push(cut);
    }
  }

  result.file = file;
  result.files = files;

  return result;
}
211035
function filterRepresented(modules, files, options) {
    return _.filter(modules, function(module) {
      return !_.some(files, function(file) {
        // Look for the module name somewhere in the source path
        return (
          path
            .join(sep, options.srcPrefix, file.src.replace(rmain, '$1'), sep)
            .indexOf(sep + module + sep) > -1
        )
      })
    })
  }
466399
function getFilesList(pattern) {
		//If pattern empty return all avaliable fonts
		if (pattern === undefined || pattern === '') {
			formatingFontsArray(serverFonts);
			closeConnection();
			return; // We are completed, close connection and end the program
		}

		var serverFiles = [],
			preg = new RegExp('[\\w\\-\\.]*' + pattern + '[\\w\\-\\.]*');


		function regular() {
			if (serverFonts.length < 1) {
				if (serverFiles.length !== 0){
					formatingFontsArray(serverFiles);
				}else{
					grunt.log.warn('We haven\'t any suitable fonts');
				}
				closeConnection();
				return; // We are completed, close connection and end the program
			}
			var file = serverFonts.pop();
			if (preg.test(file)) {
				serverFiles.push(file);
			}
			regular();
		}
		regular();
	}
408773
function getFiles(dir) {
    var files = [];

    var traverse = function (dir) {
        var dirList = dir.listFiles();
        dirList.forEach(function (file) {
            if (/\.css$/.test(file)) {
                files.push(file);
            } else if (file.isDirectory()) {
                traverse(file);
            }
        });
    };

    traverse(dir);

    return files;
}
161330
function (files) {
  return files.reduce(function (filesMap, file) {
    let fileName = path.parse(file).name;
    filesMap[fileName] = readFile(file, 'utf8');

    return filesMap;
  }, {});
}
1353479
public static List<File> listFilesByRegex(String regex, File... directories) {
        return listFiles(directories,
                new RegexFileFilter(regex),
                CanReadFileFilter.CAN_READ);
    }
446163
protected function filter_files( $files ) {
		if ( ! $files ) {
			return null;
		}

		foreach ( $files as $key => $file ) {
			if ( is_array( $file ) ) {
				$files[ $key ] = $this->filter_files( $files[ $key ] );
			}

			if ( empty( $files[ $key ] ) ) {
				unset( $files[ $key ] );
			}
		}

		return $files;
	}
1094111
private static File[] getAllFiles(String dirName, String regex) {

    File[] allFiles = getAllFiles(dirName);

    List<File> matchingFiles = new ArrayList<File>();

    for (File allFile : allFiles) {

      if (allFile.getName().matches(regex)) {
        matchingFiles.add(allFile);
      }
    }

    return matchingFiles.toArray(new File[matchingFiles.size()]);
  }
766165
function filterFiles( files ){
    var filtered = [],
        file,
        i;
    for( i = 0; i < files.length; i++ ){
        file = files[ i ];
        if( file.height &&
            file.width &&
            file.url ){
            //This is sufficient to serve as a level
            filtered.push({
                url: file.url,
                width: Number( file.width ),
                height: Number( file.height )
            });
        }
        else {
            $.console.error( 'Unsupported image format: %s', file.url ? file.url : '<no URL>' );
        }
    }

    return filtered.sort(function(a, b) {
        return a.height - b.height;
    });

}