mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
update package pidusage`s definition to version 2.0.14
This commit is contained in:
Vendored
+50
-6
@@ -1,12 +1,56 @@
|
||||
// Type definitions for pidusage 1.1
|
||||
// Type definitions for pidusage 2.0
|
||||
// Project: https://github.com/soyuka/pidusage
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// wujingtao <https://github.com/mx601595686>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Stat {
|
||||
cpu: number;
|
||||
memory: number;
|
||||
/**
|
||||
* @param pids A pid or a list of pids.
|
||||
* @param callback Called when the statistics are ready.
|
||||
*/
|
||||
declare function pidusage(pids: number | number[] | string | string[], callback: (err: Error | null, stats: pidusage.Stat) => void): void;
|
||||
/**
|
||||
* @param pids A pid or a list of pids.
|
||||
*/
|
||||
declare function pidusage(pids: number | number[] | string | string[]): Promise<pidusage.Stat>;
|
||||
|
||||
declare namespace pidusage {
|
||||
interface Stat {
|
||||
/**
|
||||
* percentage (from 0 to 100*vcore)
|
||||
*/
|
||||
cpu: number;
|
||||
|
||||
/**
|
||||
* bytes
|
||||
*/
|
||||
memory: number;
|
||||
|
||||
/**
|
||||
* PPID
|
||||
*/
|
||||
ppid: number;
|
||||
|
||||
/**
|
||||
* PID
|
||||
*/
|
||||
pid: number;
|
||||
|
||||
/**
|
||||
* ms user + system time
|
||||
*/
|
||||
ctime: number;
|
||||
|
||||
/**
|
||||
* ms since the start of the process
|
||||
*/
|
||||
elapsed: number;
|
||||
|
||||
/**
|
||||
* ms since epoch
|
||||
*/
|
||||
timestamp: number;
|
||||
}
|
||||
}
|
||||
|
||||
export function stat(pid: number, callback: (error: Error, stat: Stat) => void): void;
|
||||
export function unmonitor(pid: number): void;
|
||||
export = pidusage;
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
import pusage = require("pidusage");
|
||||
import * as pidusage from 'pidusage';
|
||||
|
||||
pusage.stat(0, (err: Error, stat: pusage.Stat) => {
|
||||
const cpu = stat.cpu;
|
||||
const memory = stat.memory;
|
||||
let cpu: number;
|
||||
let memory: number;
|
||||
let ppid: number;
|
||||
let pid: number;
|
||||
let ctime: number;
|
||||
let elapsed: number;
|
||||
let timestamp: number;
|
||||
|
||||
pidusage(1, (err: Error | null, stats: pidusage.Stat) => {
|
||||
cpu = stats.cpu;
|
||||
memory = stats.memory;
|
||||
ppid = stats.ppid;
|
||||
pid = stats.pid;
|
||||
ctime = stats.ctime;
|
||||
elapsed = stats.elapsed;
|
||||
timestamp = stats.timestamp;
|
||||
});
|
||||
|
||||
pusage.unmonitor(0);
|
||||
let stats: Promise<pidusage.Stat>;
|
||||
|
||||
stats = pidusage([1, 2]);
|
||||
stats = pidusage('string');
|
||||
stats = pidusage(['string', 'string']);
|
||||
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// Type definitions for pidusage 1.1
|
||||
// Project: https://github.com/soyuka/pidusage
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Stat {
|
||||
cpu: number;
|
||||
memory: number;
|
||||
}
|
||||
|
||||
export function stat(pid: number, callback: (error: Error, stat: Stat) => void): void;
|
||||
export function unmonitor(pid: number): void;
|
||||
@@ -0,0 +1,8 @@
|
||||
import pusage = require("pidusage");
|
||||
|
||||
pusage.stat(0, (err: Error, stat: pusage.Stat) => {
|
||||
const cpu = stat.cpu;
|
||||
const memory = stat.memory;
|
||||
});
|
||||
|
||||
pusage.unmonitor(0);
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"pidusage": [ "pidusage/v1.1" ]
|
||||
},
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"pidusage-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user