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

dirp-tree

v0.1.0

Published

Powerful, Async Filetree Generator.

Downloads

7

Readme

DIRP-TREE

powerful, async filetree generator

NOTE: dirptree is in an early/development state; expect breaking changes until the first major version, 1.0.0.

v0.2.0 TODO:

  • [feat] allow for callback in file object
  • [feat] allow optional file write tag
    • for path & file in their respective objects
  • [feat] implement a .copy() method
  • [chore] extensive testing (and benchmarking ?)
  • [refactor] implement mkdirp to reduce dependencies
  • [doc] improve documentation on config object structure

###What is dirp-tree???

This module is essentially a very fast file-tree generator; it uses async and parallel control flow, to first create directories in breadth-first order, then fill those directories depth-first.

Why is that worth mentioning?

The result is an array of streams in the order they traditionally depend upon each other. While currently we can consider it a 'sapling', dirp-tree is already a useful, extensible tool for use in your development workflow.


###How it works:

  1. npm install dirp-tree
  2. In the file you want to use it: const dirptree = require('dirp-tree');
  3. Invoke the dirptree: dirptree();
  4. ???
  5. Profit

###In more detail...

The dirp-tree will accept two optional arguments, the first is an object that defines the structure of your dirp-tree(example below), the second is a string representing the absolute path in which your dirp-tree will be planted.

Like so: dirptree([file_tree][,root_path]);

The file_tree argument will default to the object exported by your dirptree.config.js file, place it at the root directory of your project (next to the node_modules folder).

If you've neglected to configure your dirp-tree, fear not, the module provides a basic config file, resembling your average Node.js MVC app, that it defaults to.

The root_path argument will default to your project's root directory. If you want to hand a root_path argument to your dirp-tree, be careful! Make sure that it's a complete path from the root directory, otherwise you may end up with some unexpected results...

Invoking the dirptree results in a Promise which, if successful, is handed an array of Node.js WriteStream objects (opened in a+ mode). This functionality is under active development and may change in the future; if you have any feature-requests, don't hesitate to reach out.


###Example tree structure:

const mytree = {
    name: 'app/dirptree', // defines the folder name
    // all subfolders (ie 'app') will also be created
    files: [
      'roots.js',
      // Files can be strings,
      // or objects with a source to pipe from;
      // stream transform support is coming soon!
      { name: 'seeds.js', src: 'src/seedfile.js' },
      { name: 'bark.js', src: 'src/barkfile.js' }
    ],
    paths: [
      'leaves',
      // Paths can be strings too;
      // the path object resemble the tree object,
      // this makes dirp_tree easy to modularize
      { name: 'trunk', files: ['branch.js','twigs.json'] },
      { name: 'drunk', files: ['water.js','roots.json'] }
    ]
};

// if you're using dirp_tree with a dirptree.config.js,
// don't forget to export your tree!
module.exports = mytree;

If you have any questions about dirp-tree, or maybe you have some awesome features to recommend, feel free to file an issue and I'll be in touch!