file-size-tree
v0.0.0
Published
Take a list of file paths in Node, and get back an object matching d3's hierarchy layout format
Downloads
63
Readme
file-size-tree
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
}]