dir-iterate-recursive
v1.0.1
Published
recursively walk a directory and execute a callback
Downloads
2
Readme
Dir Iterate Recursive
Recursively walk a directory and execute a function on each file. The function must either be synchronous or return a promise.
var iterate = require('dir-iterate-recursive')
var fs = require('mz/fs')
iterate(__dirname, function (file) {
return fs.stat(file).then(function (stat) {
console.log(stat.size)
})
}).then(function () {
console.log('done!')
}).catch(function (err) {
console.error(err.stack)
})
API
iterate(directory, fn)
directory
must be the absolute path of the directory.
fn
must either be synchronous or return a promise.
fn
is called with fn(file, stats)
where file
is the the absolute path of the file and stats
is the fs.stats()
object.