Take a list of file paths in Node, and get back an object matching d3's hierarchy layout format.
JavaScript
Switch branches/tags
Nothing to show
Latest commit 35a51e4 Jul 20, 2013 @hughsk hughsk first commit
Permalink
Failed to load latest commit information.
LICENSE.md first commit Jul 20, 2013
README.md first commit Jul 20, 2013
index.js first commit Jul 20, 2013
package.json first commit Jul 20, 2013

README.md

file-size-tree unstable

Take a list of file paths in Node, and get back an object matching d3's hierarchy layout format. Great for making easy treemaps and the like.

Installation

npm install file-size-tree

Usage

require('file-size-tree')(files)

Takes an array of filenames and returns an object in d3's hierarchy layout format. For example, this:

var fileTree = require('file-size-tree')

fileTree([
    __dirname + '/project/src/index.js'
  , __dirname + '/project/src/README.md'
  , __dirname + '/project/src/package.json'
  , __dirname + '/LICENSE'
])

Should result in this:

[{
 "name": "project",
 "children": [
  {
   "name": "src",
   "children": [
    {"name": "index.js", "size": 3938},
    {"name": "README.md", "size": 3812},
    {"name": "package.json", "size": 743}
   ]
  }
 ]
}, {
 "name": "LICENSE",
 "size": 526
}]