UNPKG

filter-files

Version:

Recursively read directories and return a list of files, filtered to have only the files for which the (optional) filter function returns `true`. Sync and async.

10 lines (9 loc) 217 B
'use strict'; module.exports = function filter(files, dir, fn, recurse) { if (typeof fn !== 'function') { return files; } return files.filter(function (fp) { return fn(fp, dir, files, recurse); }); };