file-tree
Generate a tree of file metadata that matches d3's hierarchy layout format
Last updated 12 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install file-tree 
SYNC missed versions from official npm registry.

file-tree

A more flexible, asynchronous version of file-size-tree.

Installation

npm install file-tree

Usage

require('file-tree')(files, mapper, callback)

Takes an array of files.

mapper(filename, next) should pass an object to the the callback with the metadata you want to associate with the file.

callback(err, tree) is called when everything's done.

var tree = require('file-tree')
var fs = require('fs')

tree([
    __dirname + '/project/src/index.js'
  , __dirname + '/project/src/README.md'
  , __dirname + '/project/src/package.json'
  , __dirname + '/LICENSE'
], function(filename, next) {
  fs.stat(filename, function(err, stats) {
    if (err) return next(err)
    next(null, {
      size: stats.size
    })
  })
}, function(err, fileTree) {
  console.log(fileTree) // done!
})

Current Tags

  • 1.0.0                                ...           latest (12 years ago)

2 Versions

  • 1.0.0                                ...           12 years ago
  • 0.0.0                                ...           13 years ago
Maintainers (1)
Downloads
Total 8
Today 0
This Week 0
This Month 8
Last Day 0
Last Week 2
Last Month 0
Dependencies (3)
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE