Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mscdex/xsys
A node.js binding to useful system-level functions
https://github.com/mscdex/xsys
Last synced: 3 months ago
JSON representation
A node.js binding to useful system-level functions
- Host: GitHub
- URL: https://github.com/mscdex/xsys
- Owner: mscdex
- License: mit
- Created: 2012-05-20T00:21:25.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-08-04T12:17:19.000Z (over 11 years ago)
- Last Synced: 2024-09-17T09:24:56.767Z (4 months ago)
- Language: C++
- Homepage:
- Size: 50.8 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Description
===========A [node.js](http://nodejs.org/) binding to useful system-level functions.
Requirements
============* [node.js](http://nodejs.org/) -- v0.6.0 or newer
Install
============npm install xsys
Examples
========* Get filesystem total/free/used byte counts:
```javascript
var fs = require('xsys').fs;// format our numerical output
function fmtBytes(val) {
return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}fs.getTotal(function(err, n) {
if (err) throw err;
console.log('Total bytes for current volume: ' + fmtBytes(n));
});
fs.getFree(function(err, n) {
if (err) throw err;
console.log('Free bytes for current volume: ' + fmtBytes(n));
});
fs.getUsed(function(err, n) {
if (err) throw err;
console.log('Used bytes for current volume: ' + fmtBytes(n));
});// sample output:
//
// Total bytes for current volume: 974,656,999,424
// Free bytes for current volume: 877,061,001,216
// Used bytes for current volume: 48,814,333,952
```API
===Static Methods
--------------* **fs.getTotal**([<_String_>path,] <_Function_>callback) - _(void)_ - Retrieves the number of total bytes on the volume where *path* is located (defaults to path of the module). The callback receives two arguments: an <_Error_> object in case of error (null otherwise) and a <_String_> containing the number of bytes.
* **fs.getTotalSync**([<_String_>path]) - <_String_> - Synchronous version of getTotal().
* **fs.getFree**([<_String_>path,] <_Function_>callback) - _(void)_ - Retrieves the number of free bytes on the volume where *path* is located (defaults to path of the module). The callback receives two arguments: an <_Error_> object in case of error (null otherwise) and a <_String_> containing the number of bytes.
* **fs.getFreeSync**([<_String_>path]) - <_String_> - Synchronous version of getFree().
* **fs.getUsed**([<_String_>path,] <_Function_>callback) - _(void)_ - Retrieves the number of used bytes on the volume where *path* is located (defaults to path of the module). The callback receives two arguments: an <_Error_> object in case of error (null otherwise) and a <_String_> containing the number of bytes.
* **fs.getUsedSync**([<_String_>path]) - <_String_> - Synchronous version of getUsed().