https://github.com/code2life/node-disk
Get physical disk information in Node.js
https://github.com/code2life/node-disk
Last synced: 15 days ago
JSON representation
Get physical disk information in Node.js
- Host: GitHub
- URL: https://github.com/code2life/node-disk
- Owner: Code2Life
- License: mit
- Created: 2018-04-18T05:35:48.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-13T14:48:45.000Z (over 7 years ago)
- Last Synced: 2025-01-12T10:47:41.732Z (over 1 year ago)
- Language: C++
- Size: 13.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Node-disk
Node-disk is a C++ addon node.js module for get physical disk information. Now it support windows platform, will support linux & macOS soon.
# Usage
npm install node-disk --save
```js
const disk = require('node-disk');
const info = disk.getDisk((err, data) => {
//data is disk information
});
//or invoke like this
disk.getDisk().then((data) => {
//support promise or async/await
}).catch((err) => {
//error info
});
//or query by volumes
disk.getDisk('C:', (err, data) => { });
//or like this, it's ok to pass a single letter, since it just compare first letter in windows
(async () => {
let info = await disk.getDisk('D');
})()
```
# Data Format
Disk information includes total and free size of disk currently. Plan to implement other info in future.
```js
{
total: '1042.04 GB',
free: '781.00 GB',
volumes: [{
name: 'C:\\',
total: '78.74 GB',
free: '31.18 GB'
}
]
}
```
# Todo
- Support linux and macOS
- Get more info about hardware
- Refector by using nan(Native Abstractions for Node.js)
- Add docs and mocha test cases
# Licence & copyright
Copyright (c) 2018 Code2Life
Node-disk is licensed under an MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.