node-readfiles
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "node-readfiles", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "A lightweight Node.js module to recursively read files in a directory", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -149,3 +149,35 @@ # node-readfiles | ||
A simple example that works like `find` | ||
```javascript | ||
var readfiles = require('node-readfiles'); | ||
var path = require('path'); | ||
function fileSize(size) { | ||
var unit = 'B'; | ||
if (size > 1000000000) { | ||
unit = 'T'; | ||
size /= 1000000000; | ||
}else if (size > 1000000) { | ||
unit = 'M'; | ||
size /= 1000000; | ||
}else if (size > 1000) { | ||
unit = 'K'; | ||
size /= 1000; | ||
} | ||
return (Math.round(size * 10) / 10) + unit; | ||
} | ||
var basepath = path.resolve(process.cwd(), process.argv.pop()); | ||
readfiles(basepath, { | ||
readContents: false | ||
}, function (err, filename, content, stat) { | ||
console.log(filename, fileSize(stat.size), (stat.mode & 0777).toString(8)); | ||
}, function (err, files, count) { | ||
console.log('\nTotal of', count, 'file(s) found\n'); | ||
}); | ||
``` | ||
## License | ||
MIT licensed (See LICENSE.txt) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27368
183