df
node-df
(abbreviation of disk free) is a cross-platform Node.js wrapper around the standard Unix computer program, df.
Installation
$ npm install node-df
Usage
Basic
var df = ; ;
Output from df
looks like this:
Values for size
, used
and available
are expressed in KiB
(1024 bytes).
Value for capacity
is a number between 0
and 1
. capacity
is also known as used%
node-df
correctly parsed output from df
unix program for filesystems and mount folders with whitespaces in the name.
Advanced
var
options = {
file: '/',
prefixMultiplier: 'GB',
isDisplayPrefixMultiplier: true,
precision: 2
};
df(options, function (error, response) {
if (error) { throw error; }
console.log(JSON.stringify(response, null, 2));
});
Output from df
now looks like this:
Options
- file: output the amount of free space of the file system containing the specified file;
- prefixMultiplier: convert
size
,used
andavailable
values fromKiB
toMiB
,GiB
,PiB
,EiB
,ZiB
,YiB
,MB
,GB
,PB
,EB
,ZB
,YB
; - isDisplayPrefixMultiplier: if
true
, values forsize
,used
andavailable
are converted to strings andprefixMultiplier
is displayed (see example above). - precision: round
size
,used
andavailable
values toprecision
decimal digits.