mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add definition for node-memwatch
Some of types are brought from @cyrilschumacher's memwatch-next definition.
This commit is contained in:
parent
8cfe3b2c5a
commit
b08cef6666
87
types/node-memwatch/index.d.ts
vendored
Normal file
87
types/node-memwatch/index.d.ts
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
// Type definitions for node-memwatch 1.0
|
||||
// Project: https://github.com/eduardbcom/node-memwatch#readme
|
||||
// Definitions by: Eunchong Yu <https://github.com/Kroisse>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
export = memwatch;
|
||||
|
||||
declare const memwatch: MemWatch;
|
||||
|
||||
interface MemWatch extends EventEmitter {
|
||||
on(eventName: "leak", callback: (event: LeakInformation) => void): this;
|
||||
on(eventName: "stats", callback: (event: StatsInformation) => void): this;
|
||||
|
||||
/**
|
||||
* Force V8 to do a full GC and heap compaction.
|
||||
*
|
||||
* It's intended to be used for debugging. Calling it in production is highly discouraged.
|
||||
*/
|
||||
gc(): void;
|
||||
|
||||
HeapDiff: typeof HeapDiff;
|
||||
}
|
||||
|
||||
interface StatsInformation {
|
||||
current_base: number;
|
||||
estimated_base: number;
|
||||
heap_compactions: number;
|
||||
max: number;
|
||||
min: number;
|
||||
num_full_gc: number;
|
||||
num_inc_gc: number;
|
||||
usage_trend: number;
|
||||
}
|
||||
|
||||
interface LeakInformation {
|
||||
/**
|
||||
* Amount of heap growth in bytes.
|
||||
*/
|
||||
growth: number;
|
||||
|
||||
/**
|
||||
* Human-readable description.
|
||||
*/
|
||||
reason: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the state of your heap between two points in time, telling you what has been allocated, and what has been released.
|
||||
*/
|
||||
declare class HeapDiff {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Compute the diff.
|
||||
*/
|
||||
end: () => HeapDiffInformation;
|
||||
}
|
||||
|
||||
interface HeapDiffInformation {
|
||||
before: HeapDiffSnapshot;
|
||||
after: HeapDiffSnapshot;
|
||||
change: HeapDiffChange;
|
||||
}
|
||||
|
||||
interface HeapDiffSnapshot {
|
||||
nodes: number;
|
||||
size_bytes: number;
|
||||
size: string;
|
||||
}
|
||||
|
||||
interface HeapDiffChange {
|
||||
size_bytes: number;
|
||||
size: string;
|
||||
freed_nodes: number;
|
||||
allocated_nodes: number;
|
||||
details: HeapDiffDetail[];
|
||||
}
|
||||
|
||||
interface HeapDiffDetail {
|
||||
what: string;
|
||||
size_bytes: number;
|
||||
size: string;
|
||||
"+": number;
|
||||
"-": number;
|
||||
}
|
||||
14
types/node-memwatch/node-memwatch-tests.ts
Normal file
14
types/node-memwatch/node-memwatch-tests.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import memwatch = require("node-memwatch");
|
||||
|
||||
memwatch.on("stats", info => {
|
||||
info.estimated_base;
|
||||
});
|
||||
|
||||
memwatch.on("leak", info => {
|
||||
info.growth;
|
||||
});
|
||||
|
||||
const hd = new memwatch.HeapDiff();
|
||||
const diff = hd.end();
|
||||
diff.change.allocated_nodes;
|
||||
diff.change.details[0].what;
|
||||
23
types/node-memwatch/tsconfig.json
Normal file
23
types/node-memwatch/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"node-memwatch-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/node-memwatch/tslint.json
Normal file
1
types/node-memwatch/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user