Reviewing some TypeScript code and I came across this and I am not sure what it means:
type data = {
serial_number: string;
hub_sn: string;
};
type rapid = data & {
type: "rapid";
ob: number[];
};
I see rapid referenced with a listener:
listen.on("rapid", async (data: rapid) => {
const [ts, ob] = decodeRapid(data.ob);
const body = `rapid,station=${data.serial_number} ${
serialize(ob)
} ${ts}`;
const response = await writeToInfluxDB(body);
console.log(JSON.stringify({ response, body }));
});
I am kind of lost on how the data from the listener is fed into the objects??