directory-tree
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"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" |
[![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. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4796
131
124611