npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tree-manager

v0.0.2

Published

Display and manage directory tree. Connector for jstree.

Downloads

4

Readme

tree-manager

nodejs connector for jstree library.

To run the example go to example folder run npm install and point your browser to localhost:5000.

Initialization

var TreeManager = require('../lib/treemanager');
var rootDir = __dirname + '/test_dir_root';
var treeManager = new TreeManager(rootDir);

Set the root path whil instantiating the module.

You can change the root directory on the fly by calling treeManager.setRoot(path) with a path as an argument.

Methods

walkDir

Walks down recursivelly the root folder.

Example:

treeManager.walkDir(rootDir, function (err, tree) {
  console.log(tree);
});

Parameters:

  • rootDirectory - absolute path to rd
  • callback - function called on success or error, returns error object or an object with the directory structure

createNode

Creates a new file or folder

Example:

var type = 'file';
var filename = path.join(req.query.id, req.query.text);
treeManager.createNode(filename, type, function (res) {
  console.log(res);
});

Parameters:

  • name - path to a new file or folder
  • type - file or folder
  • callback - function called on success or error, returns error object or new folder or file name.

renameNode

Renames a file or folder

Example:

treeManager.renameNode('some_dir/note.txt', 'note_changed.txt', function (res) {
  console.log(res);
});

Parameters:

  • oldPath - path to the current file or folder
  • newName - new name for the file or folder
  • callback - function called on success or error, returns error object or changed file path

deleteNode

Removes file or folder. Folders are removed recursivelly.

Example:

treeManager.deleteNode('some_dir/notes.txt', function (res) {
  console.log(res);
});

Parameters:

  • nodePath Relative path of the node to be removed
  • callback - function called on success or error, returns error object or path of the removed node

moveNode

Moves node

Example:

treeManager.moveNode('some_dir/notes.txt', 'next_level/other_dir', function (res) {
  res.send(res);
});

Parameters:

  • nodePath Relative path of the node to be moved
  • nodeParent Relative path of the parent target node
  • callback - function called on success returns new path to the node

Tests

To perform tests run npm test in the tree-manager root directory.

TODO

  • 2 option for folder removal - recursive with all subfolders and files and only empty
  • check performance of walkDir function for larger directory structure
  • check uniqueness after renaming and moving - server side
  • write file to example