Giter VIP home page Giter VIP logo

fd-diskspace's Introduction

Checks disk space stats in bytes

Supports Windows and Linux system. Check with the utility:

  • Windows - wmic logicaldisk get size,freespace,caption
  • Linux - df

Installation

NPM

npm install fd-diskspace --save

Usage

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
    }
  }
}
 */

API

diskSpace(callback)

Params

  • Function callback - callback fucntion
    • Error err - callback error
    • Object res - callback result about disk space

diskSpaceSync()

Return

  • Object res - result about disk space

Response structure

  • Object res
    • Object total - sum of all disk space
      • Integer free - free disk space
      • Integer size - total size of disk
      • Integer used - used disk space
      • Integer percent - percent of used disk space
    • Object disks - named disks. Contain full analogue disks.total Object

Test

Run the mocha test

Current test runs for 12-16 ms

npm test

Build form coffee source

Build project

The source code in the folder development. They should be compiled in the bin folder


Changelog

1.0.0 [ Stable ]

  • Add - first realise

fd-diskspace's People

Contributors

littleskunk avatar superpaintman avatar superpaintmanbot avatar workfunction avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.