directory-tree-scheme
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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

Dependencies (1)

Dev Dependencies (1)

Package Sidebar

Install

npm i directory-tree-scheme

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

6.63 kB

Total Files

7

Last publish

Collaborators

  • dcfgvy