Dev Helpers
← Back

Skip preparing an unused event

Skip preparing an unused event using Node.js.

Open this example in the interactive library

Source code

import { channel, subscribe, unsubscribe } from "node:diagnostics_channel";
const name = "helpers:sample";
const ch = channel(name);
console.log(ch.hasSubscribers ? { expensive: "payload" } : "skipped");

Sample output

skipped