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

disk-cleanup

v1.0.2

Published

This project offers a set of functions to perform disk cleanup operations in Node.js, including backup creation, restoration, and removal of files and directories.

Downloads

13

Readme

disk-cleanup

This project offers a set of functions to perform disk cleanup operations in Node.js, including backup creation, restoration, and removal of files and directories.

Prerequisites:

  • Make sure you have Node.js installed on your system.

Installation:

    npm install disk-cleanup

Usage:

Removing Temporary Files

  • The removeTemporary function is used to delete temporary files from a specified directory.

  •       const diskCleanup = require('disk-cleanup');
    
      diskCleanup.removeTemporary('/path/to/directory', (err, result) => {
          if (err) {
              console.error('Error:', err);
          } else {
              console.log('Result:', result);
          }
      });
    

Backup and Restore

  • This package also offers backup and restore functionalities.

    *const diskCleanup = require('disk-cleanup');

    *const backupPath = diskCleanup.createBackupDirectory('/path/to/directory');

    • this function will create a backup directory inside the directory given by you.
    • If path of directory is not given than backup directory will be created in current working directory.
    • console.log('Backup directory created at:', backupPath);

    *diskCleanup.backupFile("/path/of/file","/path/of/backup directory");

    • this function will backup a file you provided by path inside backup directory path you provided.
    • if path of backup directory is not given it will search for backup directory in current working directory/

    *diskCleanup.restoreBackup( "filename","backupPath", "dirPath");

    • restore the backup file
    • backuppath- backup directory path inside which the file is saved or backup.
    • filename- the name of file
    • dirpath- path of directory where you want to restore
    • If backup path is not given than it will search for backup directory in you current working directory
    • if dirPath is not given than it will also restore the files in the current working directory.

    *diskCleanup.removeBackupFile( "fileName", "backupPath");

    • removes the backup file
    • backuppath- this is the path of backup directory
    • filename- file name u want to delete
    • If backupPath is not given than it will search for backup directory in current working directory

    *diskCleanup.removeBackupdir("backupPath");

    • remove the backup directory all the backup will be deleted
    • backuppath- path of backup directory you want to delete
    • If backupPath is not given than it will search for backup directory in current working directory

Filter by File Size

  • 
      const diskCleanup = require('disk-cleanup');
    
    
      //size will given in the bytes in all functions
      // Deletes files of a specified size from a given directory.
      diskCleanup.filterEqual('/path/to/directory', size, (err, result) => { 
          if (err) {
              console.error('Error:', err);
          } else {
              console.log('Result:', result);
          }
      });
    
    
      //Deletes files greater than a specified size from a given directory.
      diskCleanup.filterGreater('/path/to/directory', size, (err, result) => {
      if (err) {
          console.error('Error:', err);
      } else {
          console.log('Result:', result);
      }
      });
    
    
      //Deletes files smaller than a specified size from a given directory.
      diskCleanup.filterSmaller('/path/to/directory', size, (err, result) => {
      if (err) {
          console.error('Error:', err);
      } else {
          console.log('Result:', result);
      }
      });
    
    
    
      //if u know size not in bytes than you can simply convert by functions:
      diskCleanup.filterSmaller('/path/to/directory', kb_to_bytes(size in bytes), (err, result) => {
      if (err) {
          console.error('Error:', err);
      } else {
          console.log('Result:', result);
      }
      });
    
    
    
    
        

Size conversion

  • convert the data size into bytes usefull for filtering functions.
  • 
      kb_to_bytes(20) // convert 20 kb into bytes
      mb_to_bytes(20) //20 mb to bytes
      gb_to_bytes(10) 
      tb_to_bytes(20)
      pb_to_bytes(20)
      eb_to_bytes(20)
      zb_to_bytes(20)
      yb_to_bytes(20)
    

Contributing:

  • Contributions are welcome! Please feel free to submit issues or pull requests.

License

  • This project is licensed under the MIT License.
  • Feel free to modify or expand the README further based on your preferences or any additional information you wish to provide!