{"name":"filter-files","description":"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.","version":"0.2.4","homepage":"https://github.com/jonschlinkert/filter-files","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/filter-files.git"},"bugs":{"url":"https://github.com/jonschlinkert/filter-files/issues"},"licenses":[{"type":"MIT","url":"https://github.com/jonschlinkert/filter-files/blob/master/LICENSE-MIT"}],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha -R spec"},"devDependencies":{"benchmarked":"^0.1.3","chalk":"^0.5.1","glob":"^4.0.6","mocha":"*","should":"^4.1.0","verb":"^0.2.6"},"keywords":["dir","directories","ext","extension","file","file-path","file-system","filepath","files","filter","fs","javascript","js","path","util","utils"],"dependencies":{"async":"^0.9.0","is-directory":"^0.2.2"},"_id":"filter-files@0.2.4","_shasum":"be13b73e81bf353c3005e2fa78fb9850eeb084f2","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"be13b73e81bf353c3005e2fa78fb9850eeb084f2","tarball":"http://registry-npm.ywwl.com/filter-files/download/filter-files-0.2.4.tgz","integrity":"sha512-NziSMx95tC4+zdVmB4IhomaHMuQxPI9yKp49+VzpjzbX3Vp03z72uAb7mYpX7ItZ98I6WPqkXOUHqmKicFlPeQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCvbMWex5WEFFBMg1D/BCrP5pWDqyrY7LQRJaxD3nbq9gIgfHuNIc2nXZH6O7t+4ojFPRubP9ten7RbaLCdgorr5Lc="}],"size":4059,"noattachment":false,"key":"/filter-files/-/filter-files-0.2.4.tgz"},"directories":{},"readme":"# filter-files [![NPM version](https://badge.fury.io/js/filter-files.svg)](http://badge.fury.io/js/filter-files)\n\n> 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.\n\n## Install\n### Install with [npm](npmjs.org)\n\n```bash\nnpm i filter-files --save\n```\n\n## Run tests\n\n```bash\nnpm test\n```\n\n## Usage\n\n```js\nvar filter = require('filter-files');\n```\n\n### sync\n\n```js\nfilter.sync(dir, [recurse], [filterFn]);\n```\n**Params**\n\n - `dir` **{String}**: the directory to start from. Returns all files, recursively, starting with this path.\n - `filterFn` **{Function}**: optionally pass a filter function to use for filtering files/dirs. This function filters \"on the fly\", so recursion is very fast.\n - `recurse` **{Boolean}**: pass `false` to disable recursion.\n\n**Examples**\n\n```js\nvar files = filter.sync('lib');\nconsole.log(files);\n//=> [ 'lib/async.js', 'lib/filter.js', 'lib/sync.js' ]\n```\n\nPass a filter function:\n\n```js\nfilter.sync('lib', function(fp) {\n  return /a/.test(fp);\n});\n//=> [ 'lib/async.js' ]\n```\n\nOr an array of filter functions:\n\n```js\nfunction include(fp) {\n  return /^\\./.test(fp);\n}\nfunction exclude(fp) {\n  return !/^\\.[jntv]/.test(fp);\n}\n\n// pass `false` to prevent recursion\nfilter('.', [include, exclude], false);\n//=> ['.git', '.gitignore', '.gitattribuets']\n```\n\n### async\n\n```js\nfilter(dir, [recurse], [filterFn], callback));\n```\n**Params**\n\nSame as sync with the addition of `callback`.\n\n**Examples**\n\n```js\nfilter('lib', function(err, files) {\n  console.log(files);\n  //=> [ 'lib/async.js', 'lib/filter.js', 'lib/sync.js' ]\n});\n```\n\nPass a filter function:\n\n```js\nvar fn = function(fp) {\n  return /a/.test(fp);\n};\n\nfilter('lib', fn, function(err, files) {\n  console.log(files);\n  //=> [ 'lib/async.js' ]\n});\n```\n\n### Filtering\n\nFilter functions take four parameters and return `true` or `false`.\n\n**Params**\n\n - `fp` filepath being looped over\n - `dir` current directory\n - `files` accumulated array of files\n - `recurse` whether recurse is `true` or `false`\n\n**Example**\n\nThis function returns a filter function for getting files with the given `extname`:\n\n```js\nvar path = require('path');\nvar isDir = require('is-directory');\n\nfunction ext(extname) {\n  // this is our filter function\n  return function filter(fp, dir, files, recurse) {\n    if (isDir(path.join(dir, fp)) && recurse === true) {\n      return true;\n    }\n    return path.extname(fp) === extname;\n  }\n}\n```\n\nSee [the tests](./test/test.js) for more examples.\n\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/filter-files/issues).\n\n## Author\n\n**Jon Schlinkert**\n \n+ [github/jonschlinkert](https://github.com/jonschlinkert)\n+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) \n\n## License\nCopyright (c) 2014 Jon Schlinkert  \nReleased under the MIT license\n\n***\n\n_This file was generated by [verb](https://github.com/assemble/verb) on November 17, 2014._","publish_time":1414655589951,"_cnpm_publish_time":1414655589951,"dist-tags":{"latest":"0.4.0"}}