Skip to main content
hasSubscribers - node__diagnostics_channel.d.ts - Node documentation
function hasSubscribers

Usage in Deno

```typescript import { hasSubscribers } from "node:node__diagnostics_channel.d.ts"; ```
hasSubscribers(name: string | symbol): boolean
Check if there are active subscribers to the named channel. This is helpful if the message you want to send might be expensive to prepare. This API is optional but helpful when trying to publish messages from very performance-sensitive code. ```js import diagnostics_channel from 'node:diagnostics_channel'; if (diagnostics_channel.hasSubscribers('my-channel')) { // There are subscribers, prepare and publish message } ```

Parameters

name: string | symbol
The channel name

Return Type

boolean
If there are active subscribers