JSPM

cs-file-tree

1.0.2
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 2
    • Score
      100M100P100Q26180F
    • License ISC

    Tree structure representation of a folder structure / file system.

    Package Exports

    • cs-file-tree

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cs-file-tree) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Synopsis

    Tree structure that represents the contents (files / folders) of a given start folder. Simply pass in a start folder and this module will return an object that you can use in a user interface to represent your files!

    ##Requirements

    Before building this project you will need the following resources:

    • npm

    Installation

    npm install cs-file-tree --save

    Usage

    There are 2 functions exposed in this module (excluding the promise wrappers): 'getList' and 'getObject'. getList returns a list off all files and folders, and getObject returns the tree structure. See below for instructions.

    Get List of Files / Folder

    var tree = require('cs-file-tree');
    tree.getList(__dirname, function(err, rslt) {
        if (err) {
            console.dir(err);
        } else {
            console.dir(rslt);
        }
    });

    Get Tree Structure

    var tree = require('cs-file-tree');
    tree.getObject(__dirname, function(err, rslt) {
        if (err) {
            console.dir(err);
        } else {
            console.dir(rslt);
        }
    });

    Promise wrappers

    For your convenience I have added wrappers to expose these functions as promises. See below for instructions.

    Get List of Files / Folders (Promise)

    var tree = require('cs-file-tree');
    tree.getList(__dirname)
        .then((rslt) => { ...do something })

    Get Tree Structure (Promise)

    var tree = require('cs-file-tree');
    tree.getObject(__dirname)
        .then((rslt) => { ...do something })