{"_id":"fileutils","_rev":"12-15d3d931e784881287bc2c0a8d79c8b7","name":"fileutils","description":"Some utilities that diminish the suck of working with the file system in node","dist-tags":{"latest":"1.0.2"},"versions":{"0.0.1":{"name":"fileutils","version":"0.0.1","description":"Some utilities that diminish the suck of working with the file system in node","keywords":["files","directories","fileutil"],"homepage":"http://github.com/lukebayes/node-fileutils","author":{"name":"Luke Bayes","email":"lbayes@patternpark.com","url":"http://lukebayes.com"},"repository":{"type":"git","url":"https://github.com/lukebayes/node-fileutils"},"main":"src/fileutils","test":"runner.js","engines":{"node":">= 0.4.0"},"_id":"fileutils@0.0.1","_engineSupported":true,"_npmVersion":"0.2.14-6","_nodeVersion":"v0.4.0","directories":{},"files":[""],"_defaultsLoaded":true,"dist":{"shasum":"f834e977be33c31e04f589e782f9e1145dc0ad33","tarball":"https://registry.npmjs.org/fileutils/-/fileutils-0.0.1.tgz","integrity":"sha512-FXJ09GTUl7yFOPRDdS7xtT92niHxJKxK8Cta5qXL7OEF0KKgz+LzaavfXrV9jvWOkXYw68uCNG3lNgG5jhoS7g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAwSma93mpwZudDoC29zN7ncnbs+WHFbilO7tfumOe1GAiBfKWkGFpzPPketqKY4oEXyryKUJUjyFz1iAe04faW6iA=="}]}},"0.1.0":{"name":"fileutils","version":"0.1.0","description":"Some utilities that diminish the suck of working with the file system in node","keywords":["files","directories","fileutil"],"homepage":"http://github.com/lukebayes/node-fileutils","author":{"name":"Luke Bayes","email":"lukebayes@gmail.com","url":"http://lukebayes.com"},"repository":{"type":"git","url":"git://github.com/lukebayes/node-fileutils.git"},"main":"src/fileutils.js","test":"runner.js","engines":{"node":">= 0.4.0"},"_npmUser":{"name":"lukebayes","email":"lukebayes@gmail.com"},"_id":"fileutils@0.1.0","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.21","_nodeVersion":"v0.6.18","_defaultsLoaded":true,"dist":{"shasum":"9ca655ab677e87d6375b1e56d9e510e0314f87b4","tarball":"https://registry.npmjs.org/fileutils/-/fileutils-0.1.0.tgz","integrity":"sha512-FYIA+HhV9aTnKiRXV8Wv0KPVM2F9HFVA0F8FVjVuMK61/VUWrynC1tNOAKzAY9n6cC8sktyKt0iyMwnRsGZ9zw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCLzhh+Y5jHM5oK5eyGXK9udkL9RSTKnRPailXKaps6DwIhAKrteFulneokHU8a/lL9zkBZq12JcU8feEL6yyn1Iwnc"}]},"scripts":{},"maintainers":[{"name":"lukebayes","email":"lbayes@patternpark.com"}]},"0.1.1":{"name":"fileutils","version":"0.1.1","description":"Some utilities that diminish the suck of working with the file system in node","keywords":["files","directories","fileutil"],"homepage":"http://github.com/lukebayes/node-fileutils","author":{"name":"Luke Bayes","email":"lukebayes@gmail.com","url":"http://lukebayes.com"},"repository":{"type":"git","url":"https://github.com/lukebayes/node-fileutils"},"main":"src/fileutils.js","files":["README.md","src/fileutils.js"],"test":"runner.js","engines":{"node":">= 0.4.0"},"license":"MIT","gitHead":"4138f66402f6518da814b3eeaee97247b3cc0822","bugs":{"url":"https://github.com/lukebayes/node-fileutils/issues"},"_id":"fileutils@0.1.1","scripts":{},"_shasum":"303e3c9cdef370a86b5cf6bcfcc5b55d88015056","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"lukebayes","email":"lukebayes@gmail.com"},"maintainers":[{"name":"lukebayes","email":"lbayes@patternpark.com"}],"dist":{"shasum":"303e3c9cdef370a86b5cf6bcfcc5b55d88015056","tarball":"https://registry.npmjs.org/fileutils/-/fileutils-0.1.1.tgz","integrity":"sha512-iyzR+ZeyNKLz0JRw9yYl8meqeVXBxNG0AG++nzzkcE75u9ogxcbbxPwYt4Vnt0Yl5RSarJsAzUsR3G6RVy1Eqw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB/8iWCLBZ9s/XWAVVKLmWT+8gJJA+C23WJoXllw6mrfAiEA5zksSigr2GgcCQocyUQN9p7x0lZjReskst565M3Jwrc="}]},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fileutils-0.1.1.tgz_1503943776521_0.05442330380901694"}},"1.0.0":{"name":"fileutils","version":"1.0.0","description":"Some utilities that diminish the suck of working with the file system in node","keywords":["files","directories","fileutil"],"homepage":"http://github.com/lukebayes/node-fileutils","author":{"name":"Luke Bayes","email":"lukebayes@gmail.com","url":"http://lukebayes.com"},"repository":{"type":"git","url":"git+https://github.com/lukebayes/node-fileutils.git"},"main":"src/fileutils.js","files":["README.md","src/fileutils.js"],"test":"runner.js","engines":{"node":">= 0.4.0"},"license":"MIT","gitHead":"428182e57c2d1c17c748ca7e85e74d60b244acb6","bugs":{"url":"https://github.com/lukebayes/node-fileutils/issues"},"_id":"fileutils@1.0.0","_npmVersion":"5.3.0","_nodeVersion":"8.3.0","_npmUser":{"name":"lukebayes","email":"lukebayes@gmail.com"},"dist":{"integrity":"sha512-7wB1H2YGvl1KD1QjZEfinK/aNpmqSEQyN80W8Nvc/hytkMbwgfj4b/hbvHO5VlZuVZv4b4ofZGzeJPPTxGJSow==","shasum":"4b14554f937b532f3f06fc9dc232c2d3a1c1d306","tarball":"https://registry.npmjs.org/fileutils/-/fileutils-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICTh1BCIooa5A6/0Vh9H4zcQEfwzPCjEvsjZXYjOweBSAiA9LKzPnjy3OoossjSs3aJ8cov/nOCQYEFoXwIVb5BFbw=="}]},"maintainers":[{"name":"lukebayes","email":"lbayes@patternpark.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fileutils-1.0.0.tgz_1503946098913_0.3300719689577818"}},"1.0.1":{"name":"fileutils","version":"1.0.1","description":"Some utilities that diminish the suck of working with the file system in node","keywords":["files","directories","fileutil"],"homepage":"http://github.com/lukebayes/node-fileutils","author":{"name":"Luke Bayes","email":"lukebayes@gmail.com","url":"http://lukebayes.com"},"repository":{"type":"git","url":"git+https://github.com/lukebayes/node-fileutils.git"},"main":"src/fileutils.js","files":["README.md","src/fileutils.js"],"test":"runner.js","engines":{"node":">= 0.4.0"},"license":"MIT","gitHead":"4bb5dcac893232bab0175dc2988c99ea37643aae","bugs":{"url":"https://github.com/lukebayes/node-fileutils/issues"},"_id":"fileutils@1.0.1","_npmVersion":"5.3.0","_nodeVersion":"8.3.0","_npmUser":{"name":"lukebayes","email":"lukebayes@gmail.com"},"dist":{"integrity":"sha512-mybq0mw81hp5ySlBf82uryvQO9S99GQ2nHYozTw2uCe+Q3cklBq0snrtjPSJmrGNedPmHWaHDMBlLlyrkmlpxQ==","shasum":"7a4272a8fedd95b003cbb617ae334ad04ee46408","tarball":"https://registry.npmjs.org/fileutils/-/fileutils-1.0.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCyPC1RDQkxG8V3Kg6ijmNI3W438QZNgpEP8/SJCeQShAIhANzKvKZpUcdwMJA2Gmt9isX36cELfiV+Uf/WkXqGkUDt"}]},"maintainers":[{"name":"lukebayes","email":"lbayes@patternpark.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fileutils-1.0.1.tgz_1503946910645_0.010722169652581215"}},"1.0.2":{"name":"fileutils","version":"1.0.2","description":"Some utilities that diminish the suck of working with the file system in node","keywords":["files","directories","fileutil"],"homepage":"http://github.com/lukebayes/node-fileutils","author":{"name":"Luke Bayes","email":"lukebayes@gmail.com","url":"http://lukebayes.com"},"repository":{"type":"git","url":"git+https://github.com/lukebayes/node-fileutils.git"},"main":"src/fileutils.js","files":["README.md","src/fileutils.js"],"test":"runner.js","engines":{"node":">= 0.4.0"},"license":"MIT","gitHead":"9ed4a10a694e3d45e39388af53258db4e655cf37","bugs":{"url":"https://github.com/lukebayes/node-fileutils/issues"},"_id":"fileutils@1.0.2","_npmVersion":"5.3.0","_nodeVersion":"8.3.0","_npmUser":{"name":"lukebayes","email":"lukebayes@gmail.com"},"dist":{"integrity":"sha512-PUsvNZav2oaf05uM1Zkjo9PbXBMcTkbwy97A46Pe2pWLYubCBxErzC7qVpd5y/HVQg8/ZImKzCWmHdvzpeT/vw==","shasum":"052ca89ae8fcefca172cf28f9b3315f921fc7e19","tarball":"https://registry.npmjs.org/fileutils/-/fileutils-1.0.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEPG4C/LiezAkmv3EI9gEqcuSChO40pNdzxv8zzCA4ooAiBadsah1iPm4jMIwKmeaAHQsAGC3wOTdxb2WldrfEUjog=="}]},"maintainers":[{"name":"lukebayes","email":"lbayes@patternpark.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fileutils-1.0.2.tgz_1503947133680_0.8221483933739364"}}},"maintainers":[{"name":"lukebayes","email":"lbayes@patternpark.com"}],"time":{"modified":"2022-06-18T00:46:50.145Z","created":"2011-02-27T16:57:50.745Z","0.0.1":"2011-02-27T16:57:51.154Z","0.1.0":"2012-08-28T00:30:10.331Z","0.1.1":"2017-08-28T18:09:37.442Z","1.0.0":"2017-08-28T18:48:19.966Z","1.0.1":"2017-08-28T19:01:53.022Z","1.0.2":"2017-08-28T19:05:34.572Z"},"author":{"name":"Luke Bayes","email":"lukebayes@gmail.com","url":"http://lukebayes.com"},"repository":{"type":"git","url":"git+https://github.com/lukebayes/node-fileutils.git"},"readme":"\nh1. Node FileUtils\n\nA collection of utilities that take some of the suck out of working with the file system in Node.\n\nh2. Installation\n\nThe package is available over npm and can be installed with:\n\n<pre><code>npm install node-fileutils\n</code></pre>\n\nOne you have it installed, you should be able to include it with:\n\n<pre><code>var fu = require('node-fileutils');\n\nfu.eachFileOrDirectory(...);\n</code></pre>\n\nOr, if you're only using one of the methods, you can require it directly with:\n\n<pre><code>var readEachFileMatching = require('node-fileutils').readEachFileMatching;\n</code></pre>\n\nh2. Examples\n\nFollowing are some examples that should make it easier to work with these utilities.\n\nh3. eachFileOrDirectory\n\nThis is the foundation method that each of the others relies on. This method was designed to address some missing features in the node File System package. When recursively, asynchronously traversing the file system, I would like a handler to be called as soon as each file (or in some cases, directory) is found, but I also want to know the following:\n\n * Were no files found?\n * Are we finished with the traversal?\n\nThe most basic implementation of traversing the file system using only the node library does give us a timely callback, but does not answer the two questions above.\n\n<code>eachFileOrDirectory</code> will recursively, asynchronously traverse the file system starting at the provided <code>directory</code> and will call <code>fileHandler</code> for each file or directory that is found. When traversal is complete, the optional <code>completeHandler</code> will be called (if it is provided).\n\n<code>fileHandler</code> is called with the following arguments:\n\n * err: Null if no error is found\n * fileOrDirectory: The file or directory name and path\n * stat: A Stat object for the file or directory\n\n<code>completeHandler</code> is called with the following arguments:\n\n * err: Null if no error is found\n * filesAndDirectories: An Array of all files and directories\n * stats: An Array of all Stat objects (indexed the same as the files)\n\nFollowing is an example of a simple, typical usage:\n\n<pre><code>eachFileOrDirectory('test/', function(err, fileOrDirectory, stat) {\n    if (err) throw err;\n    if (!stat.isDirectory()) {\n      console.log(\">> Found file: \" + fileOrDirectory);\n    } else {\n      console.log(\">> Found directory: \" + fileOrDirectory);\n    }\n  });\n</code></pre>\n\nFollowing is an example that waits for all files and directories to be \nscanned and then uses the entire result to do something:\n\n<pre><code>eachFileOrDirectory('test/', null, function(files, stats) {\n    if (err) throw err;\n    var len = files.length;\n    for (var i = 0; i < len; i++) {\n      if (!stats[i].isDirectory()) {\n        console.log(\">> Found file: \" + files[i]);\n      } else {\n        console.log(\">> Found directory: \" + files[i]);\n      }\n    }\n  });\n</code></pre>\n\nh3. eachFile\n\n<code>eachFile</code> works just like <code>eachFileOrDirectory</code>, but even though it recursively traverses the file system, it only calls callback with files, not directories.\n\nh3. eachFileMatching\n\n<code>eachFileMatching</code> works just like eachFile, but it only includes files that match a provided regualar expression.\n\nFollowing is a simple example of using eachFileMatching:\n\n<pre><code>eachFileMatching(/_test.js/, 'test', function(err, file, stat) {\n  if (err) throw err;\n  console.log(\">> Found file: \" + file);\n});\n</code></pre>\n\nh3. readEachFileMatching\n\n<code>readEachFileMatching</code> works just like <code>eachFileMatching</code>, but it also calls callback with the contents of each file that is found. Note that this method should not be used with unusually large files that you might prefer to read with buffers.\n\n<pre><code>readEachFileMatching(/_test.js/, 'test', function(err, file, stat, content) {\n  if (err) throw err;\n  console.log(\">> Found file: \" + file + \" with: \" + content.length + \" chars\");\n});\n</code></pre>\n\nh2. Issues?\n\nMessage me above on Github if you have any questions or issues. I'll expand to a group of some kind if enough people find this useful.\n\n","homepage":"http://github.com/lukebayes/node-fileutils","keywords":["files","directories","fileutil"],"bugs":{"url":"https://github.com/lukebayes/node-fileutils/issues"},"license":"MIT","readmeFilename":"README.textile"}