Skip to content

Commit

Permalink
Add types definition
Browse files Browse the repository at this point in the history
  • Loading branch information
omrilotan committed Mar 12, 2024
1 parent 7069ad7 commit 7ac1deb
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
60 changes: 60 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
declare class SDC {
constructor({
host,
port,
protocol,
protocol_version,
MTU,
timeout,
tags,
scheme,
prefix,
sanitise,
errorHandler,
enforceRate
}: {
// StatsD host [127.0.0.1]
host?: string,
// StatsD port [8125]
port?: string|number,
// Internet Protocol (UDP/TCP) [UDP]
protocol?: string,
// Internet Protocol version (ipv4/ipv6) [ipv4]
protocol_version?: string
// Maximum Transmission Unit [576]
MTU?: number,
// Maximum cutoff time (ms) until flush current metric bulk [1000]
timeout?: number,
// Default tags to be sent with every metric []
tags?,
// Format stats metric as: `'datadog'`, `'graphite'`, custom format function [datadog]
scheme?: string|(
({
type, key, value, rate, tags
}: {
type: string,
key: string,
value: number,
rate: number,
tags: string[]
}) => string),
// Prefix all stats with this value []
prefix?: string,
// Sanitise stat keys [Default sanitisation: Allow characters, numbers, underscores and dots. Replace everything else with underscore. Lowercase everything]
sanitise?: (string: string) => string,
// Handle message sending errors (see section 'Throwing errors') []
errorHandler?: Function,
// Should I enforce rate (mark as false is rate was already enforced) [true]
enforceRate?: boolean,
});
count(key: string, value: number, rate?: number, tags?: string[]): void;
time(key: string, value: number, rate?: number, tags?: string[]): void;
gauge(key: string, value: number, rate?: number, tags?: string[]): void;
set(key: string, value: number, rate?: number, tags?: string[]): void;
generic(type: string, key: string, value: number, rate?: number, tags?: string[]): void;
histogram(key: string, value: number, rate?: number, tags?: string[]): void;
get size(): number;
destroy(): void;
}

export default SDC;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fiverr/statsd-client",
"version": "1.1.0",
"version": "1.1.1",
"description": "📈 A feature packed, highly customisable StatsD client",
"keywords": [
"StatsD",
Expand All @@ -24,6 +24,7 @@
},
"homepage": "https://fiverr.github.io/node-statsd-client",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"predocs": "which docsify || npm i --no-save docsify-cli",
"docs": "docsify serve docs -p 6375",
Expand Down

0 comments on commit 7ac1deb

Please sign in to comment.