diff --git a/usage/usage-tests.ts b/usage/usage-tests.ts new file mode 100644 index 000000000..af8a3b275 --- /dev/null +++ b/usage/usage-tests.ts @@ -0,0 +1,19 @@ +/// +/// + +import usage = require('usage'); + +var pid = process.pid; +var options = { keepHistory: true }; + +usage.lookup(pid, function(err, result) { + console.log("Usage infos", result); +}); + +usage.lookup(pid, options, function (err, result) { + console.log("Usage infos with history", result); +}); + +usage.clearHistory(pid); +usage.clearHistory(); + diff --git a/usage/usage.d.ts b/usage/usage.d.ts new file mode 100644 index 000000000..194bfcd7d --- /dev/null +++ b/usage/usage.d.ts @@ -0,0 +1,28 @@ +// Type definitions for usage +// Project: https://github.com/arunoda/node-usage +// Definitions by: Pascal Vomhoff +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "usage" { + + export interface ResultObject { + memory:number; + memoryInfo: { + rss:number; + vsize:number; + } + cpu:number; + } + + export interface Options { + keepHistory:boolean; + } + + export function lookup(pid:number, callback:(err:Error, result:ResultObject) => void); + export function lookup(pid:number, options:Options, callback:(err:Error, result:ResultObject) => void); + + //Only availible on linux + export function clearHistory(pid?:number); + + +} \ No newline at end of file