Json File Tree for Node JS - IoT Shaman
Tree structure representing the contents of a given system drive. Simply pass in a start folder, or a list of files / folders, and this module will return an object that you can use in a user interface to represent your files!
Requirements
In order to use node-json-file-tree you will need the following resource(s):
- npm
Installation
npm install node-json-file-tree --save
Quick Start
The file tree structure can be created in 1 of 2 ways, either by providing a list of files / folders to it's constructor, or using the "seed" factory and providing an address for the root directory.
File Tree Seed (factory method)
Use this factory method to generate a file "seed". A seed will "grow" a file tree for you, first running a recursive directory scan, then converting the results into a file tree. This method is asynchornous and is provided as a Promise.
Methods
getwindows?: boolean = false: Promise<FileTreeSeed>;
Implementation
let ftsf = FileTreeSeedFactory// generate file tree seed from factoryftsf;
Manaul (via constructor)
When you already have a list of files / folders, you can manually populate a new instance of FileTree.
let FileTree = FileTree;let tree = '/path/to/file.txt' '/path/to/';// ...
File Tree Structure
The file tree object has the below definition (in Typescript):
Given the below list of files / folders, the file tree would look like:
- /small/path.txt
- /longer/folder/path2.txt
"small": "_files_": "path.txt" "longer": "folder": "_files_": "path2.txt" "_files_": "_files_":
API Reference
--eof