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 3.1.0 to 3.2.0

1

index.d.ts

@@ -21,2 +21,3 @@ import { Stats } from 'fs';

isSymbolicLink?: boolean;
custom: { [key: string]: any };
}

@@ -23,0 +24,0 @@ export interface DirectoryTreeOptions {

2

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

@@ -5,0 +5,0 @@ "repository": {

@@ -169,2 +169,29 @@ [![Build Status](https://api.travis-ci.com/mihneadb/node-directory-tree.svg?branch=master)](https://api.travis-ci.com/mihneadb/node-directory-tree.svg?branch=master)

## Adding custom fields
You can easily extend a `DirectoryTree` object with custom fields by adding them to the custom field.
For example add an `id` based on the path of a `DirectoryTree` object for each directory and file like so:
```
import { createHash } from 'crypto';
import * as directoryTree from 'directory-tree';
import { DirectoryTree, DirectoryTreeOptions, DirectoryTreeCallback } from 'directory-tree';
const callback: DirectoryTreeCallback = (
item: DirectoryTree,
path: string
) => {
item.custom.id = createHash('sha1').update(path).digest('base64');
};
const dirTree: DirectoryTree & { id?: string } = directoryTree(
"<your-directory-path>",
{},
callback,
callback
);
// to explore the object with the new custom fields
console.log(JSON.stringify(dirTree, null, 2));
```
## Note

@@ -171,0 +198,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