Update pidusage-tests.ts

This commit is contained in:
wujingtao
2019-01-14 18:32:26 +08:00
committed by GitHub
parent dba4b88578
commit d26f6be7e7
+16 -9
View File
@@ -1,4 +1,4 @@
import pidusage, { Stat } from 'pidusage';
import * as pidusage from 'pidusage';
let cpu: number;
let memory: number;
@@ -8,7 +8,7 @@ let ctime: number;
let elapsed: number;
let timestamp: number;
pidusage(1, (err: Error | null, stats: Stat) => {
pidusage(1, (err: Error | null, stats: pidusage.Status) => {
cpu = stats.cpu;
memory = stats.memory;
ppid = stats.ppid;
@@ -18,7 +18,7 @@ pidusage(1, (err: Error | null, stats: Stat) => {
timestamp = stats.timestamp;
});
pidusage('two', (err: Error | null, stats: Stat) => {
pidusage('two', {}, (err: Error | null, stats: pidusage.Status) => {
cpu = stats.cpu;
memory = stats.memory;
ppid = stats.ppid;
@@ -28,11 +28,18 @@ pidusage('two', (err: Error | null, stats: Stat) => {
timestamp = stats.timestamp;
});
pidusage([1, 'two'], (err: Error | null, stats: { [key: string]: Stat }) => {
const one: Stat = stats[1];
const two: Stat = stats.two;
pidusage([1, 'two'], (err: Error | null, stats: { [key: string]: pidusage.Status }) => {
const one: pidusage.Status = stats[1];
const two: pidusage.Status = stats.two;
});
const stats_1: Promise<Stat> = pidusage(1);
const stats_two: Promise<Stat> = pidusage('two');
const stats_obj: Promise<{ [key: string]: Stat }> = pidusage([1, 'two']);
pidusage([1, 'two'], {}, (err: Error | null, stats: { [key: string]: pidusage.Status }) => {
const one: pidusage.Status = stats[1];
const two: pidusage.Status = stats.two;
});
const stats_1: Promise<pidusage.Status> = pidusage(1);
const stats_two: Promise<pidusage.Status> = pidusage('two', {});
const stats_obj: Promise<{ [key: string]: pidusage.Status }> = pidusage([1, 'two']);
const stats_obj_config: Promise<{ [key: string]: pidusage.Status }> = pidusage([1, 'two'], {});