mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
os-utils 0.0.14: Add types (#39377)
This commit is contained in:
committed by
Wesley Wigham
parent
d9fbafa34f
commit
fd4b44df45
102
types/os-utils/index.d.ts
vendored
Normal file
102
types/os-utils/index.d.ts
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
// Type definitions for os-utils 0.0
|
||||
// Project: https://github.com/oscmejia/os-utils
|
||||
// Definitions by: Nasreddine Bac Ali <https://github.com/bacali95>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
type Platform = 'aix'
|
||||
| 'android'
|
||||
| 'darwin'
|
||||
| 'freebsd'
|
||||
| 'linux'
|
||||
| 'openbsd'
|
||||
| 'sunos'
|
||||
| 'win32'
|
||||
| 'cygwin';
|
||||
|
||||
/**
|
||||
* returns platform.
|
||||
* @return Platform
|
||||
*/
|
||||
export function platform(): Platform;
|
||||
|
||||
/**
|
||||
* returns number of cpus.
|
||||
* @return number
|
||||
*/
|
||||
export function cpuCount(): number;
|
||||
|
||||
/**
|
||||
* returns system up time in seconds.
|
||||
* @return number
|
||||
*/
|
||||
export function sysUptime(): number;
|
||||
|
||||
/**
|
||||
* returns process up time in seconds.
|
||||
* @return number
|
||||
*/
|
||||
export function processUptime(): number;
|
||||
|
||||
/**
|
||||
* returns free memory in megabytes.
|
||||
* @return number
|
||||
*/
|
||||
export function freemem(): number;
|
||||
|
||||
/**
|
||||
* returns total memory in megabytes.
|
||||
* @return number
|
||||
*/
|
||||
export function totalmem(): number;
|
||||
|
||||
/**
|
||||
* returns the percentage of free memory.
|
||||
* @return number
|
||||
*/
|
||||
export function freememPercentage(): number;
|
||||
|
||||
/**
|
||||
* execute free command (only linux).
|
||||
*/
|
||||
export function freeCommand(callback: (used_mem: number) => any): void;
|
||||
|
||||
/**
|
||||
* execute df -k command.
|
||||
*/
|
||||
export function harddrive(callback: (total: number, free: number, used: number) => any): void;
|
||||
|
||||
/**
|
||||
* return process running current.
|
||||
*/
|
||||
export function getProcesses(callback: (result: string) => any): void;
|
||||
|
||||
/**
|
||||
* return process running current.
|
||||
*/
|
||||
export function getProcesses(nProcess: number, callback: (result: string) => any): void;
|
||||
|
||||
/**
|
||||
* returns all the load average usage for 1, 5 or 15 minutes.
|
||||
* @return string
|
||||
*/
|
||||
export function allLoadavg(): string;
|
||||
|
||||
/**
|
||||
* returns the load average usage for 1, 5 or 15 minutes.
|
||||
* @return number
|
||||
*/
|
||||
export function loadavg(_time?: number): number;
|
||||
|
||||
/**
|
||||
* returns the free percentage of cpu usage.
|
||||
*/
|
||||
export function cpuFree(callback: (percentage: number) => any): void;
|
||||
|
||||
/**
|
||||
* returns the percentage of cpu usage.
|
||||
*/
|
||||
export function cpuUsage(callback: (percentage: number) => any): void;
|
||||
|
||||
export {};
|
||||
38
types/os-utils/os-utils-tests.ts
Normal file
38
types/os-utils/os-utils-tests.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import * as os from 'os-utils';
|
||||
|
||||
console.log('\n');
|
||||
console.log('OS Utils');
|
||||
console.log('\n');
|
||||
|
||||
console.log('Platform: ' + os.platform());
|
||||
console.log('CPUs: ' + os.cpuCount());
|
||||
console.log('\n');
|
||||
|
||||
console.log('System Uptime (s): ' + os.sysUptime());
|
||||
console.log('Process Uptime (s): ' + os.processUptime());
|
||||
console.log('\n');
|
||||
|
||||
console.log('Free Memory (Kb): ' + os.freemem());
|
||||
console.log('total Memory (Kb): ' + os.totalmem());
|
||||
console.log('Free Memory (%): ' + os.freememPercentage());
|
||||
console.log('\n');
|
||||
|
||||
console.log('Load Usage (%): ' + os.loadavg());
|
||||
console.log('Load Usage 1 (%): ' + os.loadavg(1));
|
||||
console.log('Load Usage 5 (%): ' + os.loadavg(5));
|
||||
console.log('Load Usage 15 (%): ' + os.loadavg(15));
|
||||
console.log('\n');
|
||||
|
||||
os.cpuUsage((v) => {
|
||||
console.log('CPU Usage (%): ' + v);
|
||||
});
|
||||
|
||||
os.cpuFree((v) => {
|
||||
console.log('CPU Free (%): ' + v);
|
||||
});
|
||||
|
||||
console.log('\n');
|
||||
console.log('OS Utils');
|
||||
console.log('\n');
|
||||
|
||||
console.log('\n');
|
||||
24
types/os-utils/tsconfig.json
Normal file
24
types/os-utils/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"os-utils-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/os-utils/tslint.json
Normal file
3
types/os-utils/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user