1.0.3 • Published 1 year ago

directory-tree-scheme v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

directory-tree-scheme

Creates a plain text scheme or a JS object representing the directory tree. This package is an improvement of directory-tree by @mihneadb.

Install

$ npm install directory-tree-scheme

Usage

For example, we have a directory called photos that looks like this: Photos directory screenshot

import { build_scheme } from "directory-tree-scheme";

const tree = build_scheme("/path-to/photos-directory");
console.log(tree);

Running the code above will console log the following plain text tree:

├── notes.txt
├── summer
│   └── june
│       └── windsurf.txt
└── winter
    ├── december
    │   ├── christmas.txt
    │   ├── fun.txt
    │   └── new_year.txt
    └── january
        ├── ski.txt
        └── snowboard.txt

You can also get the tree as a JS object:

import { build_tree } from "directory-tree-scheme";

const tree = build_tree("/path-to/photos-directory");
console.log(tree);

Running the code above will console log the following plain text tree:

{
  path: '/photos',
  name: 'photos',
  children: [
    {
      path: '/photos/notes.txt',
      name: 'notes.txt'
    },
    {
      path: '/photos/summer',
      name: 'summer',
      children: [Array]
    },
    {
      path: '/photos/winter',
      name: 'winter',
      children: [Array]
    }
  ]
}

Other

Full documentation can be found here

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago