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

dir-roll-up

v1.8.0

Published

Module to get space usage for all sub directories in a path

Downloads

31

Readme

dir-roll-up

Module to get space usage for all sub directories in a path.

Try on RunKit


Implemented as an asynchronous generator that only uses core modules:

  • Responsive and non-blocking
  • Lower runtime memory usage

Usage

Installing

npm install dir-roll-up

Examples

Each directory is returned as a node in the following format:

{
  "id": "8abf23ea00bbf8ac2ff47b6ecba9984f",
  "depth": 1,
  "fileCount": 5,
  "sizeOfDir": 2032,
  "rollupSize": 259737,
  "dirName": ".git",
  "parent": "5058f1af8388633f609cadb75a75dc9d"
}

1) Directories aggregated

List all directories under current location. Each node is only returned once, when its total size is aggregated, resulting in a bottom-up retrieval.

const dirRollUp = require("dir-roll-up");

(async () => {
  for await (let dirNode of dirRollUp(".")) {
    console.log(dirNode);
  }
})();

2) Directories including partial updates

Directories are repeatedly emitted as the total size is increased for each aggregated sub directory. This is configured by passing an option {includePartial: true}

const dirRollUp = require("dir-roll-up");

(async () => {
  for await (let dirNode of dirRollUp(".", {includePartial: true})) {
    console.log(dirNode);
  }
})();

3) Get directories from an interval

Get each directory node, as required (in an interval loop), as an example of the non-blocking approach

const dirRollUp = require("dir-roll-up");

const dirNodeGenerator = dirRollUp(".");

const interval = setInterval(async () => {

  /**
   * Get the next directory...
   */
  const dirNode = await dirNodeGenerator.next();

  /**
   * ..display it..
   */
  console.log(dirNode.value);

  /**
   * ..and end the interval when last directory retrieved (which will be the root)
   */
  if (dirNode.done) {
    console.log("Finished!");
    clearInterval(interval);
  }
}, 300);