CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-wolfy87-eventemitter

Event based JavaScript for the browser with comprehensive event management API

91

1.26x
Overview
Eval results
Files

task.mdevals/scenario-7/

Event Listener Inspector

Create a utility that inspects and reports on event listeners registered in an EventEmitter instance. The utility should provide detailed information about which events have listeners and how many listeners are attached to each event.

Capabilities

Event Listener Count Reporting

  • Given an EventEmitter instance with multiple events, the utility returns a count of listeners for each event @test
  • When an event has no listeners, it reports a count of zero @test

Active Event Detection

  • The utility identifies which events have at least one listener attached @test
  • Events with no listeners are excluded from the active events list @test

Listener Function Extraction

  • Given an EventEmitter and an event name, the utility extracts all listener functions for that event as a plain array @test

Implementation

@generates

API

/**
 * Returns a map of event names to listener counts
 *
 * @param {EventEmitter} emitter - The EventEmitter instance to inspect
 * @param {Array<string>} eventNames - Array of event names to check
 * @returns {Object} Object mapping event names to their listener counts
 */
function getListenerCounts(emitter, eventNames) {
  // IMPLEMENTATION HERE
}

/**
 * Returns an array of event names that have at least one listener
 *
 * @param {EventEmitter} emitter - The EventEmitter instance to inspect
 * @param {Array<string>} eventNames - Array of event names to check
 * @returns {Array<string>} Array of event names with active listeners
 */
function getActiveEvents(emitter, eventNames) {
  // IMPLEMENTATION HERE
}

/**
 * Extracts all listener functions for a given event as a plain array
 *
 * @param {EventEmitter} emitter - The EventEmitter instance
 * @param {string} eventName - The name of the event
 * @returns {Array<Function>} Array of listener functions
 */
function extractListeners(emitter, eventName) {
  // IMPLEMENTATION HERE
}

module.exports = {
  getListenerCounts,
  getActiveEvents,
  extractListeners
};

Dependencies { .dependencies }

wolfy87-eventemitter { .dependency }

Provides event management capabilities for JavaScript applications in browser environments.

Install with Tessl CLI

npx tessl i tessl/npm-wolfy87-eventemitter

tile.json