https://github.com/dmotz/statmap
Output recursive directory stats as JSON for visualization and analysis.
https://github.com/dmotz/statmap
analysis cli javascript node
Last synced: about 1 year ago
JSON representation
Output recursive directory stats as JSON for visualization and analysis.
- Host: GitHub
- URL: https://github.com/dmotz/statmap
- Owner: dmotz
- License: mit
- Created: 2013-11-25T01:17:53.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-27T20:49:25.000Z (over 12 years ago)
- Last Synced: 2025-06-09T12:08:58.730Z (about 1 year ago)
- Topics: analysis, cli, javascript, node
- Language: JavaScript
- Homepage:
- Size: 133 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# statmap
#### Output recursive directory stats as JSON for visualization and analysis.
[Dan Motzenbecker](http://oxism.com), MIT License
[@dcmotz](http://twitter.com/dcmotz)
### Installation and Usage
**As a system executable:**
```
$ npm install -g statmap
```
When used as an executable, statmap returns JSON over stdout.
To map the current directory:
```
$ statmap > stats.json
```
Pass an optional argument for a different directory:
```
$ statmap .. > parent.json
```
The JSON will contain a recursive representation of the directory and all
children. Each key is a file or directory name with a corresponding value
containing a `stats` object and a `children` object if it is a directory.
Directories also are also given a `sum` property which reflects the size of
all children recursively, unlike the typical `size` property of directory's
`stats` object.
Here's an excerpt of the output for the package itself:
```javascript
{
"statmap": {
"stats": {
"dev": 16777220,
"mode": 16877,
"nlink": 9,
"uid": 501,
"gid": 80,
"rdev": 0,
"blksize": 4096,
"ino": 141035615,
"size": 306,
"blocks": 0,
"atime": "2013-11-25T01:02:05.000Z",
"mtime": "2013-11-25T01:02:05.000Z",
"ctime": "2013-11-25T01:02:05.000Z"
},
"sum": 165329,
"children": {
"README.md": {
"stats": {
"dev": 16777220,
"mode": 33188,
"nlink": 1,
"uid": 501,
"gid": 80,
"rdev": 0,
"blksize": 4096,
"ino": 141057002,
"size": 550,
"blocks": 8,
"atime": "2013-11-25T01:02:05.000Z",
"mtime": "2013-11-25T01:01:52.000Z",
"ctime": "2013-11-25T01:01:54.000Z"
}
},
"index.js": {
"stats": {
"dev": 16777220,
"mode": 33188,
"nlink": 1,
"uid": 501,
"gid": 80,
"rdev": 0,
"blksize": 4096,
"ino": 141035626,
"size": 1180,
"blocks": 8,
"atime": "2013-11-25T01:02:06.000Z",
"mtime": "2013-11-25T00:51:31.000Z",
"ctime": "2013-11-25T00:51:31.000Z"
}
},
"node_modules": {
"stats": {
"dev": 16777220,
"mode": 16877,
"nlink": 3,
"uid": 501,
"gid": 20,
"rdev": 0,
"blksize": 4096,
"ino": 141036545,
"size": 102,
"blocks": 0,
"atime": "2013-11-25T00:53:55.000Z",
"mtime": "2013-11-24T23:00:54.000Z",
"ctime": "2013-11-24T23:00:54.000Z"
},
"sum": 124651,
"children": {
"async": {
"stats": {
//...
```
Using this data, you could create something like a
[D3 zoomable treemap](http://mbostock.github.io/d3/talk/20111018/treemap.html)
of your hard drive.
**As a library:**
```
$ npm install --save statmap
```
Pass a path and a callback:
```javascript
var statmap = require('statmap');
statmap('./spells', function(err, stats) {
console.log(utils.inspect(stats, { color: true, depth: null }));
});
```
When used as a library, a live object is returned rather than a JSON string.