Supports Windows and Linux system. Check with the utility:
- Windows -
wmic logicaldisk get size,freespace,caption
- Linux -
df
npm install fd-diskspace --save
var ds = require('fd-diskspace');
// Async
ds.diskSpace(function(err, res){
if(err) throw err;
console.log(res);
});
// Sync
var statsSync = ds.diskSpaceSync();
console.log(statsSync);
// Linux output:
/*
{
total: {
free: 24074004,
size: 31069279,
used: 6995275,
percent: 0.22515086365538126
},
disks: {
'/': {
free: 23647712,
size: 30572556,
used: 6924844,
percent: 0.22650523561065683
},
'/dev/shm': {
free: 251044,
size: 251044,
used: 0,
percent: 0
},
'/boot': {
free: 175248,
size: 245679,
used: 70431,
percent: 0.28667895912959596
}
}
}
*/
Function
callback - callback fucntionError
err - callback errorObject
res - callback result about disk space
Object
res - result about disk space
Object
resObject
total - sum of all disk spaceInteger
free - free disk spaceInteger
size - total size of diskInteger
used - used disk spaceInteger
percent - percent of used disk space
Object
disks - named disks. Contain full analogue disks.total Object
Current test runs for 12-16 ms
npm test
The source code in the folder development. They should be compiled in the bin folder
Add
- first realise