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

get-folder

v0.1.1

Published

High-Performance Folder Size Calculator.

Readme

GetFolder

🚀 High-Performance Folder Size Calculator

A modern Node.js file system analysis library designed for high-performance folder size calculation. Supports both JavaScript and TypeScript, providing a clean API and powerful customization options.

📦 Installation

npm install get-folder

🚀 Quick Start

Basic Usage

import { FolderSize } from 'get-folder';

// Calculate folder size
FolderSize.getSize('./my-folder').then(res => {
  // size is returned in [BigNumber](https://www.npmjs.com/package/bignumber.js) format
  console.log(`Folder size: ${res.size.toString()}`);
  console.log(`File count: ${res.fileCount}`);
  console.log(`Directory count: ${res.directoryCount}`);
  console.log(`Symbolic link count: ${res.linkCount}`);
});

Advanced Configuration

import { FolderSize } from 'get-folder';

// Custom options
const result = await FolderSize.getSize('./my-folder', {
  // Maximum depth limit
  maxDepth: 5,
  // Ignore file/directory patterns
  ignores: [/node_modules/, /\.git/],
  // Whether to include hidden files
  includeHidden: false,
  // Whether to include symbolic links
  includeLink: true,
  // Concurrency control
  concurrency: 2,
  // Ignore errors and continue calculation
  ignoreErrors: true,
  // Whether to check inodes to avoid counting hard links multiple times
  inodeCheck: true,
  // Error handling callback
  onError: (error) => {
    console.log(`Error: ${error.message} at ${error.path}`);
    // true=continue, false=stop
    return true;
  }
});

🔧 API Reference

FolderSize.getSize(folderPath, options?)

Core method for calculating folder size.

Parameters

  • folderPath (string): Path to the folder to analyze
  • options (FolderSizeOptions, optional): Configuration options

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | maxDepth | number | Infinity | Maximum traversal depth to limit directory levels | | ignores | RegExp[] | [] | Array of file/directory patterns to ignore | | includeHidden | boolean | true | Whether to include hidden files (simple hidden file detection, files starting with .) | | includeLink | boolean | true | Whether to include symbolic link files (shortcuts) | | concurrency | number | 2 | Number of concurrent operations, recommended value is 2 (appropriate adjustment can improve efficiency, not necessarily bigger is better) | | ignoreErrors | boolean | false | Whether to ignore errors and continue calculation | | inodeCheck | boolean | true | Whether to check inodes to avoid duplicate counting of hard links | | onError | function | () => true | Error handling callback function, returns true to ignore errors and continue execution (affected by ignoreErrors configuration), otherwise throws exception |

Return Value

Returns a Promise that resolves to FolderSizeResult:

interface FolderSizeResult {
  // Total size in bytes
  size: BigNumber;
  // Number of files
  fileCount: number;
  // Number of directories
  directoryCount: number;
  // Number of symbolic links
  linkCount: number;
}

🚀 Performance Advantages

Test Environment: node_modules directory (46,750 files, 8,889 directories, total size 899MB)

Comparison Target: get-folder-size

Comparison Results:

| Metric | Performance Improvement | |--------|------------------------| | Overall Performance | 🚀 100% improvement | | Execution Time | 🚀 Average 45% faster, fastest at only 2.1s | | Memory Usage | 💾 Average 40% savings, minimum 11MB usage | | Result Accuracy | 📏 Completely consistent |

Performance data is from developer local testing, actual performance may vary by system

📄 License

MIT License - see LICENSE file for details.