Package Exports
- @dropb/diskinfo
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@dropb/diskinfo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
diskinfo
Disk usage info on both *nix (via
df) and Windows (viaWMIC) systems
Install
npm install @dropb/diskinfoUsage examples
// JS example (Windows)
const { diskinfo } = require('@dropb/diskinfo');
diskinfo().then(result => console.log(result));
/* OUTPUT:
[{
fstype: '3',
size: 189879426220032,
used: 53218675523584,
avail: 136660750696448,
pcent: '29%',
target: 'C:'
},
{
fstype: '2',
size: 16431471132672,
used: 4540711567360,
avail: 11890759565312,
pcent: '28%',
target: 'F:'
},
{
fstype: '4',
size: 110151046529024,
used: 108627465601024,
avail: 1523580928000,
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
declare function diskinfo(file: string): Promise<DiskInfo>;
declare function diskinfo(): Promise<DiskInfo[]>;
interface DiskInfo {
/**
* POSIX - File system type
*
* Win32 - DriveType:
* - "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;
}