Skip to content

Commit

Permalink
fix(node): correct order of params for diagnostics listeners (Definit…
Browse files Browse the repository at this point in the history
  • Loading branch information
peterblazejewicz authored Apr 26, 2022
1 parent 7834070 commit 7b3903d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion types/node/diagnostics_channel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ declare module 'diagnostics_channel' {
* @return The named channel object
*/
function channel(name: string): Channel;
type ChannelListener = (name: string, message: unknown) => void;
type ChannelListener = (message: unknown, name: string) => void;
/**
* The class `Channel` represents an individual named channel within the data
* pipeline. It is use to track subscribers and to publish messages when there
Expand Down
6 changes: 4 additions & 2 deletions types/node/test/diagnostics_channel.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Channel, channel, hasSubscribers } from 'node:diagnostics_channel';

const ch1: Channel = channel('test');
function listener(name: string, data: unknown) {
}
function listener(data: unknown) {}
function anotherListener(data: unknown, name: string) {}

const active: boolean = ch1.hasSubscribers;
const name: string = ch1.name;

ch1.subscribe(listener);
ch1.subscribe(anotherListener);

ch1.unsubscribe(listener);
ch1.unsubscribe(anotherListener);

const hasSubs = hasSubscribers('test');
2 changes: 1 addition & 1 deletion types/node/v16/diagnostics_channel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ declare module 'diagnostics_channel' {
* @return The named channel object
*/
function channel(name: string): Channel;
type ChannelListener = (name: string, message: unknown) => void;
type ChannelListener = (message: unknown, name: string) => void;
/**
* The class `Channel` represents an individual named channel within the data
* pipeline. It is use to track subscribers and to publish messages when there
Expand Down
6 changes: 4 additions & 2 deletions types/node/v16/test/diagnostics_channel.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Channel, channel, hasSubscribers } from 'node:diagnostics_channel';

const ch1: Channel = channel('test');
function listener(name: string, data: unknown) {
}
function listener(data: unknown) {}
function anotherListener(data: unknown, name: string) {}

const active: boolean = ch1.hasSubscribers;
const name: string = ch1.name;

ch1.subscribe(listener);
ch1.subscribe(anotherListener);

ch1.unsubscribe(listener);
ch1.unsubscribe(anotherListener);

const hasSubs = hasSubscribers('test');

0 comments on commit 7b3903d

Please sign in to comment.