Socket
Socket
Sign inDemoInstall

file-tree

Package Overview
Dependencies
3
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    file-tree

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


Version published
Weekly downloads
3.6K
increased by205.34%
Maintainers
1
Install size
26.7 kB
Created
Weekly downloads
 

Readme

Source

file-tree

A more flexible, asynchronous version of file-size-tree.

Installation

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.

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

Keywords

FAQs

Last updated on 06 Feb 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc