Exercise 084: Pub sub channel

Track: jsintermediate · Difficulty: Hard

Problem

Implement a solution for: Pub sub channel. Your code should be readable, handle edge cases, and include at least one test or demo output.

Requirements

  • Use idiomatic JavaScript (or the relevant framework)
  • Handle empty, invalid, or boundary inputs
  • Add brief comments explaining non-obvious logic
  • Avoid unnecessary dependencies

Starter Code

  /**
 * Exercise 084 — Pub sub channel
 * @param { input: unknown } options
 * @returns unknown
 */
export function solve(options) {
  // TODO: implement
  throw new Error("Not implemented");
}
  

Hints

  1. Break the problem into smaller functions
  2. Write examples before generalizing
  3. Test with at least three input cases

Sample Solution Approach

Parse inputs, validate, transform data, return a structured result. Compare your solution with the official docs for this topic.

Stretch Goals

  • Add TypeScript types
  • Write unit tests with Vitest or Jest
  • Optimize for performance on large inputs