Socket
Book a DemoInstallSign in
Socket

@dropb/diskinfo

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dropb/diskinfo

Get disk usage info

latest
Source
npmnpm
Version
3.0.0
Version published
Maintainers
1
Created
Source

diskinfo

Disk usage info on both *nix (via df) and Windows (via WMIC) systems

npm z Build status

Install

npm install @dropb/diskinfo

Usage examples

// JS example (Windows)

const { diskinfo } = require('@dropb/diskinfo');

diskinfo()
  .then(result => console.log(result))
  .catch(err => console.error(err.message));
/* OUTPUT:
[{
    fstype: '3',
    size: 185429127168,
    used: 51971362816,
    avail: 133457764352,
    pcent: '29%',
    target: 'C:'
  },
  {
    fstype: '2',
    size: 16046358528,
    used: 4434288640,
    avail: 11612069888,
    pcent: '28%',
    target: 'F:'
  },
  {
    fstype: '4',
    size: 107569381376,
    used: 106081509376,
    avail: 1487872000,
    pcent: '99%',
    target: 'V:'
  }]
*/
// Typescript example (Ubuntu)

import { diskinfo, DiskInfo } from '@dropb/diskinfo';

async function run() {
  const result: DiskInfo = await diskinfo('./');
  console.log(result);
}
run();
/* OUTPUT:
{ fstype: '/dev/sda1',
  size: 47242534912,
  used: 21033943040,
  avail: 23785177088,
  pcent: '47%',
  target: '/' }
*/

API

/**
 * @param file - get info of the filesystem containing the specified file or directory
 * @returns promise for an object with the info for the specified file or directory
 */
function diskinfo(file: string): Promise<DiskInfo>;

/**
 * @returns promise for an array with the info for all mounted filesystem
 */
function diskinfo(): Promise<DiskInfo[]>;

/**
 * Info of the filesystem
 */
interface DiskInfo {
  /**
   * POSIX - File system type
   *
   * Win32 - Win32_LogicalDisk DriveType(as `String`!):
   * - "0": Unknown
   * - "1": No Root Directory
   * - "2": Removable Disk
   * - "3": Local Disk
   * - "4": Network Drive
   * - "5": Compact Disc
   * - "6": RAM Disk
   */
  fstype: string;
  /**
   * Total size in bytes
   */
  size: number;
  /**
   * Used size in bytes
   */
  used: number;
  /**
   * Available size in bytes
   */
  avail: number;
  /**
   * Percentage of used divided by size
   */
  pcent: string;
  /**
   * Mount point
   */
  target: string;
}

References

License

MIT

Keywords

df

FAQs

Package last updated on 02 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts