New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dir-tree

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dir-tree

Creates an object representation of a directory tree begining at a given path

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

dir-tree

Creates a JavaScript object representing the directory structure of a given path.

#API

dirTree = require('dir-tree');

Given a directory structure of the following

/demo/
     dir1/
         file1.txt
         dir2/
     dir3/
         file2.js
     file3.js

##Promises dirTree returns a promise that resolves with the directory tree object.

dirTree('/demo').then(function (tree) {
    console.log(tree);
});

The output of the above would be...

{
    'dir1': {
        'file1.txt': true,
        'dir2': {}
    },
    'dir3': {
        'file2.js': true
    },
    'file3.js': true
}

##Callbacks dirTree can also be passed a callback that will be called with the final directory tree as the only argument.

dirTree('/demo', function (tree) {
    console.log(tree);
});

FAQs

Package last updated on 31 Mar 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc