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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dir2obj

v0.0.2

Published

Turns directory structures into plain ol' JS objects and vice versa.

Downloads

6

Readme

Dir2Obj

Node package for turning directory structures into plain ol' Javascript objects and vice versa.

Issues should be reported on the issue tracker.

dir2obj is intended as a complement to git for boilerplate projects.

git ignores empty directories and empty files (see here). This presents a problem when creating project boilerplates. Should you create dummy files in required directories and have the user delete these files, or have the end user learn about the required directories and create them?

dir2obj is an easy, light-weight solution for creating directory structures and empty files. See below for example uses.

Installation

npm install --save-dev dir2obj

Example usage

In your boilerplate's gulpfile:

var gulp = require('gulp'),
    dir2obj = require('dir2obj'),
    directoryStructure = require('../dev/directory-structure.json');

gulp.task('create-dirs', function(cb) {
  dir2obj(directoryStructure).then(function() {
    cb();
  });
});

And on the command line

git clone [your repo]
npm install
gulp create-dirs

API

dir2obj.dir2obj(dir, opt)

Returns: promise

This promise resolves with an object representation of the directory. Files are empty strings and folders are directories.

dir

Type: string
Default: .

Directory to recurse.

opt

Type: object
Default: {}

Ignored for now. Will be fleshed out soon.

dir2obj.obj2dir(obj, dir, opt)

Returns: promise

This promise resolves when the directory structure has been created.

obj

Type: object
Default: {}

The object, with objects being turned into directories and everything else being turned into files.

dir

Type: string
Default: .

The directory into which to touch files and create directories.

opt

Type: object
Default: {}

Ignored for now. Will be fleshed out soon with configuration settings for handling errors, etc.

dir2obj.constants

dir2obj.constants.emptyDirectory

Value: {}

dir2obj.constants.file

Value: ''

To do

  • Better exception handling (symlinks, files existing, etc.)
  • More config options
  • Command line options

License

MIT