# file-tree

> Generate a tree of file metadata that matches d3's hierarchy layout format

Latest version **1.0.0** (published 2015-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install file-tree
pnpm add file-tree
yarn add file-tree
bun add file-tree
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-02-06 |
| First published | 2013-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | hierarchy, children, tree, file, metadata, d3 |

## Links

- npm: https://www.npmjs.com/package/file-tree
- Repository: https://github.com/hughsk/file-tree
- Issues: https://github.com/hughsk/file-tree/issues
- npm.io page: https://npm.io/package/file-tree

## Dependencies (3)

- [flat](https://npm.io/package/flat.md) ~1.0.0
- [commondir](https://npm.io/package/commondir.md) 0.0.1
- [async-reduce](https://npm.io/package/async-reduce.md) 0.0.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-02-06
- 0.0.0 — 2013-08-10

## README

# file-tree #

A more flexible, asynchronous version of
[file-size-tree](http://github.com/hughsk/file-size-tree).

## Installation ##

``` bash
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.

``` javascript
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!
})
```

---
_Source: https://npm.io/package/file-tree · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
