Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

directory-tree

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directory-tree - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

5

package.json
{
"name": "directory-tree",
"version": "1.2.0",
"version": "1.2.1",
"description": "Convert a directory tree to a JS object.",

@@ -25,2 +25,5 @@ "repository": {

},
"engines": {
"node": ">=4.2"
},
"scripts": {

@@ -27,0 +30,0 @@ "test": "mocha"

39

README.md
[![Build Status](https://travis-ci.org/mihneadb/node-directory-tree.svg)](https://travis-ci.org/mihneadb/node-directory-tree)
#directory-tree
# directory-tree
Creates an javascript object representing a directory tree.
Creates a JavaScript object representing a directory tree.
## Install
```js
npm i -S directory-tree
```bash
$ npm install directory-tree
```
## Usage
##Usage
```js
var dirTree = require('directory-tree');
var tree = dirTree('/some/path');
const dirTree = require('directory-tree');
const tree = dirTree('/some/path');
```

@@ -24,10 +22,13 @@

```js
var dirTree = require('directory-tree');
var filteredTree = dirTree('/some/path', ['.jpg', '.png']);
const dirTree = require('directory-tree');
const filteredTree = dirTree('/some/path', ['.jpg', '.png']);
```
A callback function can be executed with each file that matches the extensions provided:
```js
var dirTree = require('directory-tree');
var tree = dirtree('./test/test_data', ['.jpg'], function(item, PATH) {
const PATH = require('path');
const dirTree = require('directory-tree');
const tree = dirTree('./test/test_data', ['.jpg'], (item, PATH) => {
console.log(item);

@@ -37,5 +38,5 @@ });

The callback function takes the directory item (has path, name, size, and extension) and an instance of [node path](https://nodejs.org/api/path.html)
The callback function takes the directory item (has path, name, size, and extension) and an instance of [node path](https://nodejs.org/api/path.html).
##Result
## Result
Given a directory structured like this:

@@ -54,3 +55,3 @@

directory-tree will return this js object:
`directory-tree` will return this JS object:

@@ -127,7 +128,7 @@ ```json

Make sure you have the dev dependcies installed (e.g. `npm install .`)
Make sure you have the dev dependencies installed (e.g. `npm install .`)
## Node version
Check out version `0.1.1` if you need support for older versions of node.
This project requires at least Node v4.2.
Check out version `0.1.1` if you need support for older versions of Node.
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