1.0.1 • Published 11 years ago

dir-iterate-recursive v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
11 years ago

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.