Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/file-size-tree
Take a list of file paths in Node, and get back an object matching d3's hierarchy layout format.
https://github.com/hughsk/file-size-tree
Last synced: 12 days ago
JSON representation
Take a list of file paths in Node, and get back an object matching d3's hierarchy layout format.
- Host: GitHub
- URL: https://github.com/hughsk/file-size-tree
- Owner: hughsk
- License: other
- Created: 2013-07-20T04:08:15.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-20T04:08:27.000Z (over 11 years ago)
- Last Synced: 2024-10-17T16:41:17.154Z (22 days ago)
- Language: JavaScript
- Size: 37.1 KB
- Stars: 5
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# file-size-tree [![unstable](https://rawgithub.com/hughsk/stability-badges/master/dist/unstable.svg)](http://github.com/hughsk/stability-badges) #
Take a list of file paths in Node, and get back an object matching d3's
[hierarchy layout](https://github.com/mbostock/d3/wiki/Hierarchy-Layout)
format. Great for making easy
[treemaps](http://bl.ocks.org/mbostock/4063582) and the like.## Installation ##
``` bash
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:``` javascript
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:
``` json
[{
"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
}]
```