Socket
Socket
Sign inDemoInstall

dree

Package Overview
Dependencies
Maintainers
1
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dree - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

2

package.json
{
"name": "dree",
"version": "1.2.1",
"version": "1.2.2",
"description": "A nodejs module wich helps you handle a directory tree providing you its abstraction through tested functions and a custom configuration.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -138,6 +138,53 @@ # dree

```
## Documentation
## API
TODO
### scan
**Syntax:**
`dree.scan(path, options, fileCallback, dirCallback)`
**Description:**
Given a path, returns an object representing its directory tree. The result could be customized with options and a callback for either each file and each directory is provided. Executed syncronously. See __Usage__ to have an example.
**Parameters:**
* `path`: Is of type `string`, and is the relative or absolute path the file or directory that you want to scan
* `options`: Optional. Is of type `object` and allows you to have customize the function behaviour.
* `fileCallback`: Optional. Called each time a file is added to the tree. It provides you the node, wich **reflects** the fiven options, and its status returned by fs.stat (fs.lstat if `followLinks` option is enabled).
* `dirCallback`: Optional. Called each time a directory is added to the tree. It provides you the node, wich **reflects** the fiven options, and its status returned by fs.lstat (fs.stat if `followLinks` option is enabled).
**Options parameters:**
* `stat`: Default value: `false`. If true every node of the result will contain `stat` property, provided by `fs.lstat` or `fs.stat`.
* `normalize`: Default value: `false`. If true, on windows, normalize each path replacing each backslash `\\` with a slash `/`.
* `symbolicLinks`: Default value: `true`. If true, all symbolic links found will be included in the result. Could not work on Windows.
* `followLinks`: Default value: `false`. If true, all symbolic links will be followed, including even their content if they link to a folder. Could not work on Windows.
* `sizeInBytes`: Default value: `true`. If true, every node in the result will contain `sizeInBytes` property as the number of bytes of the content. If a node is a folder, only its considered inner files will be computed to have this size.
* `size`: Default value: `true`. If true, every node in the result will contain `size` property. Same as `sizeInBytes`, but it is a string rounded to the second decimal digit and with an appropriate unit.
* `hash`: Default value: `true`. If true, every node in the result will contain `hash` property, computed by taking in consideration the name and the content of the node. If the node is a folder, all his considered inner files will be used by the algorithm.
* `hashAlgorithm`: Values: `md5`(default) and `sha1`. Hash algorithm used by `cryptojs` to return the hash.
* `hashEncoding`: Values: `hex`(default), `latin1` and `base64`. Hash encoding used by `cryptojs` to return the hash.
* `showHidden`: Default value: `true`. If true, all hidden files and dirs will be included in the result. A hidden file or a directory has a name wich starts with a dot and in some systems like Linux are hidden.
* `depth`: Default value: `undefined`. It is a number wich says the max depth the algorithm can reach scanning the given path. All files and dirs wich are beyound the max depth will not be considered by the algorithm.
* `exclude`: Default value: `undefined`. It is a regex or array of regex and all the matched paths will not be considered by the algorithm.
* `extensions`: Default value: `undefined`. It is an array of strings and all the files whose extension is not included in that array will be skipped by the algorithm. If value is `undefined`, all file extensions will be considered, if it is `[]`, no files will be included.
**Result object parameters:**
* `name`: Always returned. The name of the node as a string.
* `path`: Always returned. The absolute path of the node.
* `relativePath`: Always returned. The relative path from the root of the node.
* `type`: Always returned. Values: `file` or `directory`.
* `isSymbolicLink`: Always returned. A boolean with true value if the node is a symbolic link.
* `sizeInBytes`: The size in bytes of the node, returned as a number.
* `size`: The size of the node, returned as a string rounded to two decimals and appropriate unit.
* `hash`: The hash of the node.
* `extension`: The extension (without dot) of the node. Returned only if the node is a file.
* `stat`: The `fs.lstat` or `fs.fstat` of the node.
* `children`: An array of object structured like this one, containing all the children of the node.
This is also the structure of the callbacks first parameter.
## Note

@@ -144,0 +191,0 @@

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