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

uniapp-plus-plugin-cache-size

v1.3.1

Published

A utility to get the size of a directory and format the size in human-readable format for uni-app

Readme

File UserData Size Utils 📦

A utility for calculating directory sizes and converting bytes to human-readable formats, tailored for uni-app applications. This package allows you to calculate the size of any given directory in your uni-app project and clean up user data (cache, files, etc.) easily. It's a simple tool for managing storage in uni-app apps.

Features ✨

  • Directory Size Calculation: Calculate the total size of files within a specific directory (including nested subdirectories).
  • Size Formatting: Convert raw byte size to a human-readable format like B, KB, MB, GB, etc.
  • Clean User Data: A utility for clearing out cache or user-generated files in uni-app applications.
  • Remove Directory: A utility for removing a specified directory (including all contents) in uni-app applications, such as the path: /storage/emulated/0/Android/data/packageName/apps/appid/doc/video .
  • Optimized Bundle Size: Using Vite to build the bundle and Tree Shaking to reduce the final size.

Installation 🚀

You can install the package via npm:

npm install uniapp-plus-plugin-cache-size  

or

pnpm add uniapp-plus-plugin-cache-size

Usage 📑

This package provides two main functions:

1. getDirSize(url: string, callback: (totalSize: number) => void): void

Calculate the total size of a specified directory. It supports nested directories and returns the size in bytes.

Example:

import { getDirSize, formatSize } from 'uniapp-plus-plugin-cache-size';

// Get the size of '_doc/video/' directory
getDirSize('_doc/video/', (size) => {
  console.log('Directory Size:', formatSize(size));  // E.g., "Directory Size: 45.3 MB"
});

2. formatSize(bytes: number): string

Format the size in bytes into a human-readable string, converting it into units like B, KB, MB, GB, etc.

Example:

const sizeInBytes = 1048576;  // 1MB in bytes
console.log(formatSize(sizeInBytes));  // Output: "1.00 MB"

3. deleteDir(url: string): void

Clears the files in a specified directory to free up storage space, perfect for cleaning up user data or cached files in a uni-app application.

Example:

import { deleteDir } from 'uniapp-plus-plugin-cache-size';

// Clear cache in '_doc/video/' directory
deleteDir('_doc/video/');

Why Use This? 🤔

  • Space Management: As your uni-app app grows, it can accumulate a lot of cache and files. Use this utility to quickly calculate storage usage and clear up space.
  • User Data Cleanup: Perfect for apps where users can upload or store files. Easily clear out old data or cache to optimize performance.
  • Compatibility: Works with uni-app and HTML5+ environments, making it ideal for mobile and cross-platform applications.

Contributing 💪

Contributions are welcome! If you'd like to improve this utility, feel free to open issues or submit pull requests.

How to contribute:

  1. Fork the repository
  2. Create a new branch for your feature/bugfix
  3. Submit a pull request with your changes

License 📜

This project is licensed under the MIT License - see the LICENSE file for details.


👨‍💻 Developed by cherishtao

Thanks for using uniapp-plus-plugin-cache-size! 😎