mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
optimizing type definition
This commit is contained in:
Vendored
+5
-9
@@ -3,16 +3,12 @@
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// wujingtao <https://github.com/mx601595686>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/**
|
||||
* @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 function pidusage(pid: number | string, callback: (err: Error | null, stats: pidusage.Stat) => void): void;
|
||||
declare function pidusage(pids: Array<number | string>, callback: (err: Error | null, stats: { [key: string]: pidusage.Stat }) => void): void;
|
||||
declare function pidusage(pid: number | string): Promise<pidusage.Stat>;
|
||||
declare function pidusage(pids: Array<number | string>): Promise<{ [key: string]: pidusage.Stat }>;
|
||||
|
||||
declare namespace pidusage {
|
||||
interface Stat {
|
||||
|
||||
@@ -18,8 +18,21 @@ pidusage(1, (err: Error | null, stats: pidusage.Stat) => {
|
||||
timestamp = stats.timestamp;
|
||||
});
|
||||
|
||||
let stats: Promise<pidusage.Stat>;
|
||||
pidusage('two', (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;
|
||||
});
|
||||
|
||||
stats = pidusage([1, 2]);
|
||||
stats = pidusage('string');
|
||||
stats = pidusage(['string', 'string']);
|
||||
pidusage([1, 'two'], (err: Error | null, stats: { [key: string]: pidusage.Stat }) => {
|
||||
const one: pidusage.Stat = stats[1];
|
||||
const two: pidusage.Stat = stats.two;
|
||||
});
|
||||
|
||||
const stats_1: Promise<pidusage.Stat> = pidusage(1);
|
||||
const stats_two: Promise<pidusage.Stat> = pidusage('two');
|
||||
const stats_obj: Promise<{ [key: string]: pidusage.Stat }> = pidusage([1, 'two']);
|
||||
|
||||
Reference in New Issue
Block a user