{
  "name": "node-dir",
  "version": "0.0.10",
  "description": "asynchronous file and directory operations for Node.js",
  "main": "index",
  "homepage": "https://github.com/fshost",
  "author": {
    "name": "Nathan Cartwright",
    "email": "fshost@yahoo.com",
    "url": "https://github.com/fshost"
  },
  "directories": {
    "lib": "lib"
  },
  "scripts": {
    "test": "node ./test/test.js"
  },
  "engines": {
    "node": ">= 0.10.5"
  },
  "licenses": [
    "MIT"
  ],
  "keywords": [
    "node-dir",
    "directory",
    "dir",
    "subdir",
    "file",
    "asynchronous",
    "Node.js",
    "fs"
  ],
  "readme": "# node-dir\r\nA small node.js module to provide some convenience methods for asynchronous, non-blocking, recursive directory operations like being able to get an array of all files, subdirectories, or both (with the option to either combine or separate the results), and for sequentially reading and processing the contents all files in a directory recursively, optionally firing a callback when finished.\r\n\r\n#### methods\r\nFor the sake of brevity, assume that the following line of code precedes all of the examples.\r\n\r\n```javascript\r\nvar dir = require('node-dir');\r\n```\r\n\r\n#### readFiles( dir, [options], fileCallback, [finishedCallback] )\r\nSequentially read the content of each file in a directory, passing the contents to a callback, optionally calling a finished callback when complete.  The options and finishedCallback arguments are not required.\r\n\r\nValid options are:\r\n- encoding: file encoding (defaults to 'utf8')\r\n- match: a regex pattern to specify filenames to operate on\r\n- exclude: a regex pattern to specify filenames to ignore\r\n- shortName: whether to aggregate only the base filename rather than the full filepath\r\n\r\n```javascript\r\ndir.readFiles(__dirname,\r\n    function(err, content, next) {\r\n        if (err) throw err;\r\n        console.log('content:', content);\r\n        next();\r\n    },\r\n    function(err, files){\r\n        if (err) throw err;\r\n        console.log('finished reading files:',files);\r\n    });\r\n\r\n// match only filenames with a .txt extension and that don't start with a `.´\r\ndir.readFiles(__dirname, {\r\n    match: /.txt$/,\r\n    exclude: /^\\./\r\n    }, function(err, content, next) {\r\n        if (err) throw err;\r\n        console.log('content:', content);\r\n        next();\r\n    },\r\n    function(err, files){\r\n        if (err) throw err;\r\n        console.log('finished reading files:',files);\r\n    });\r\n\r\n// the callback for each file can optionally have a filename argument as its 3rd parameter\r\n// and the finishedCallback argument is optional, e.g.\r\ndir.readFiles(__dirname, function(err, content, filename, next) {\r\n        console.log('processing content of file', filename);\r\n        next();\r\n    });\r\n```\r\n\r\n        \r\n#### files( dir, callback )\r\nAsynchronously iterate the files of a directory and its subdirectories and pass an array of file paths to a callback.\r\n    \r\n```javascript\r\ndir.files(__dirname, function(err, files) {\r\n    if (err) throw err;\r\n    console.log(files);\r\n});\r\n```\r\n\r\n        \r\n#### subdirs( dir, callback )\r\nAsynchronously iterate the subdirectories of a directory and its subdirectories and pass an array of directory paths to a callback.\r\n\r\n```javascript\r\ndir.subdirs(__dirname, function(err, subdirs) {\r\n    if (err) throw err;\r\n    console.log(subdirs);\r\n});\r\n```\r\n\r\n\r\n#### paths(dir, [combine], callback )\r\nAsynchronously iterate the subdirectories of a directory and its subdirectories and pass an array of both file and directory paths to a callback.\r\n\r\nSeparated into two distinct arrays (paths.files and paths.dirs)\r\n\r\n```javascript\r\ndir.paths(__dirname, function(err, paths) {\r\n    if (err) throw err;\r\n    console.log('files:\\n',paths.files);\r\n    console.log('subdirs:\\n', paths.dirs);\r\n});\r\n```\r\n\r\n\r\nCombined in a single array (convenience method for concatenation of the above)\r\n\r\n```javascript\r\ndir.paths(__dirname, true, function(err, paths) {\r\n    if (err) throw err;\r\n    console.log('paths:\\n',paths);\r\n});\r\n```\r\n\r\n#### contributors\r\n- [Nathan Cartwright](https://github.com/fshost)\r\n- [robatron](https://github.com/robatron)\r\n- [nazomikan](https://github.com/nazomikan)\r\n\r\n## License\r\nMIT licensed (See LICENSE.txt)\r\n",
  "readmeFilename": "README.md",
  "_id": "node-dir@0.0.10",
  "dist": {
    "shasum": "61f1ecadfdfda4dea389237f689908fab5f8558f"
  },
  "_from": "node-dir@0.0.10",
  "_resolved": "https://registry.npmjs.org/node-dir/-/node-dir-0.0.10.tgz"
}
