Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: wrapTimer function types #8428

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/lib/util/metrics-helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-param-reassign */
import type EventEmitter from 'events';
import timer from './timer';

// wrapTimer keeps track of the timing of a async operation and emits
Expand All @@ -8,11 +8,14 @@ import timer from './timer';
// It transparently passes the data to the following .then(<func>)
//
// usage: promise.then(wrapTimer(bus, type, { payload: 'ok' }))
const wrapTimer: (EventEmitter, string, object) => (any) => any = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're touching this file, I also think these comments are outdated.

eventBus,
event,
args = {},
) => {
type TimeMetrics = {
[key: string]: string | number;
};
const wrapTimer: (
eventBus: EventEmitter,
type: string,
args: TimeMetrics,
) => (args: any) => any = (eventBus, event, args = {}) => {
const t = timer.new();
return (data) => {
args.time = t();
Expand Down
Loading