0.3.2 • Published 6 years ago
jsdf v0.3.2
Installation
jsdf
is published on npm
npm install --save jsdf
User Guide
const df = require('jsdf');
df('.', (err, out) => {
console.log(out);
});
Should produce output (depending on your filesystem) similar to:
{ '/':
{ filesystem: '/dev/sda1',
blocks: 245084444,
used: 54700392,
available: 177864784,
fill: 0.24 } }
API
jsdf
module exports single function
jsdf(options, done)
options argument is optional. If it's omitted df will return statistics for all available
file systems, with default formatting. If argument is a string, it will be considered as a path
specifying filesystem to be checked.
Otherwise jsdf
expects an object with following optional parameters:
Option | Type | Description |
---|---|---|
path | String | Path passed to df, command specifying filesystem to be checked |
base | String | Base size unit used for output formatting. Can be G, M or K (GB, MB or KB - default) |
decimals | Number | Number of decimal places for output size rounding |
done is a callback function that will be invoked with formatted output of df command. Expected
signature follows a standard error first pattern: done(error, output)
. If no error occurred,
output should be a dictionary object with following structure:
Type | Description | |
---|---|---|
key | String | Mounting point of a filesystem |
value | Object | Details of the filesystem size |
value.filesystem | String | Filesystem name |
value.blocks | Number | Total size of filesystem blocks (unit depends on formatting) |
value.used | Number | Size of used filesystem blocks (unit depends on formatting) |
value.available | Number | Size of available filesystem blocks (unit depends on formatting) |
value.fill | Number | Filesystem fill ratio |
df({path: '.', base: 'G', decimals: '3'}, (err, out) => {
console.log(out);
});