dir-iterate-recursive

1.0.1 • Public • Published

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.

/dir-iterate-recursive/

    Package Sidebar

    Install

    npm i dir-iterate-recursive

    Weekly Downloads

    1

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • jongleberry
    • swatinem