2018-04-10 19:09:26 +02:00
|
|
|
const WindowsPlatform = require('./platforms/windows');
|
|
|
|
const LinuxPlatform = require('./platforms/linux');
|
|
|
|
const DarwinPlatform = require('./platforms/darwin');
|
|
|
|
|
|
|
|
|
|
|
|
function getMethods() {
|
|
|
|
const classes = {
|
2018-04-10 19:44:46 +02:00
|
|
|
'win32': WindowsPlatform,
|
|
|
|
'linux': LinuxPlatform,
|
|
|
|
'android': LinuxPlatform,
|
|
|
|
'darwin': DarwinPlatform
|
2018-04-10 19:09:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
return classes[process.platform];
|
|
|
|
}
|
|
|
|
|
|
|
|
const methods = getMethods();
|
|
|
|
|
|
|
|
function total() {
|
|
|
|
return methods.getTotalMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
function used() {
|
|
|
|
return methods.getUsedMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
function free() {
|
|
|
|
return methods.getFreeMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {total, used, free};
|