add declarations for gc-stats

This commit is contained in:
Vitor Fernandes
2018-08-21 10:53:25 +01:00
parent b3c691dcd2
commit b957cd030c
4 changed files with 69 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
import GCStats = require("gc-stats");
import { GCStatistics } from "gc-stats";
const gcStats = GCStats();
gcStats.on("stats", (stats: GCStatistics) => {
const { gctype: gcType, startTime, endTime, before, after, diff } = stats;
const beforeMallocedMemory = before.mallocedMemory;
const afterMallocedMemory = after.mallocedMemory;
const diffMallocedMemory = diff.mallocedMemory;
});

34
types/gc-stats/index.d.ts vendored Normal file
View File

@@ -0,0 +1,34 @@
// Type definitions for gc-stats 1.2
// Project: https://github.com/dainis/node-gcstats#readme
// Definitions by: Vitor Fernandes <https://github.com/vfernandestoptal>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { EventEmitter } from "events";
declare namespace GCStats {
interface MemoryStatistics {
totalHeapSize: number;
totalHeapExecutableSize: number;
usedHeapSize: number;
heapSizeLimit: number;
totalPhysicalSize: number;
totalAvailableSize: number;
mallocedMemory: number;
peakMallocedMemory: number;
}
interface GCStatistics {
startTime: number;
endTime: number;
pause: number;
pauseMS: number;
gctype: 1 | 2 | 4 | 8 | 15;
before: MemoryStatistics;
after: MemoryStatistics;
diff: MemoryStatistics;
}
}
declare function GCStats(): EventEmitter;
export = GCStats;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"gc-stats-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }