1.0.3 • Published 6 months ago
@types/tx2 v1.0.3
Installation
npm install --save @types/tx2
Summary
This package contains type definitions for tx2 (https://github.com/pm2/tx2).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/tx2.
index.d.ts
// Type definitions for tx2 1.0
// Project: https://github.com/pm2/tx2
// Definitions by: Sasial <https://github.com/sasial-dev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import EventEmitter = require('node:events');
interface ErrorObject {
name: string;
message: string;
}
interface Metric<T> {
val: () => T;
set: (data: T) => void;
}
interface MetricOptions<T> {
name: string;
value: T;
unit?: string;
}
interface Counter {
val: () => number;
inc: (amount: number) => void;
dec: (amount: number) => void;
reset: () => void;
}
interface CounterOptions {
name: string;
unit: string;
}
declare class TX2 extends EventEmitter {
event(name: string, data: object): void;
action(action_name: string, callback: (cb: (data: any) => void) => void): void;
action<T extends object>(
action_name: string,
options: T,
callback: (options: T, cb: (data: any) => void) => void,
): void;
issue(err: string): string;
issue(err: Error): ErrorObject;
metric<T>(name: string, cb: () => T): Metric<T>;
metric(name: string, cb: number): Metric<number>;
metric<T>(name: string, unit: string, cb: () => T): Metric<T>;
metric(name: string, unit: string, cb: number): Metric<number>;
metric<T>(options: MetricOptions<T>): Metric<T>;
counter(name: string | CounterOptions): Counter;
}
declare const tx2: TX2;
export = tx2;
Additional Details
- Last updated: Mon, 18 Apr 2022 21:01:24 GMT
- Dependencies: @types/node:events, @types/node
- Global values: none
Credits
These definitions were written by Sasial.