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-9/

EventEmitter Integration Manager

Build a library loader utility that safely integrates multiple versions of EventEmitter in a browser environment without namespace conflicts.

Requirements

You need to create a utility module that:

  1. Loads EventEmitter and immediately stores it under a custom namespace to prevent conflicts
  2. Restores the global EventEmitter namespace to its previous value (if any existed)
  3. Returns the stored EventEmitter instance for use in the application
  4. Provides a way to verify that the global namespace has been properly restored

The utility should handle scenarios where:

  • EventEmitter is already defined globally before your code loads
  • EventEmitter needs to be isolated to prevent conflicts with other libraries
  • The original global value (if any) needs to be preserved and restored

Test Cases

  • Loading EventEmitter and calling the utility returns a usable EventEmitter instance that can create event emitters @test
  • After calling the utility, the global EventEmitter is restored to its previous value (or undefined if nothing was there before) @test
  • The returned EventEmitter instance can still create fully functional event emitters with working on/emit functionality @test

Implementation

@generates

API

/**
 * Safely loads EventEmitter and isolates it from the global namespace.
 * Restores the previous global.EventEmitter value (if any).
 *
 * @returns {Function} The EventEmitter constructor isolated from global scope
 */
function loadEventEmitter() {
  // IMPLEMENTATION HERE
}

module.exports = { loadEventEmitter };

Dependencies { .dependencies }

wolfy87-eventemitter { .dependency }

Provides event management capabilities for JavaScript applications

Install with Tessl CLI

npx tessl i tessl/npm-wolfy87-eventemitter

tile.json