{"library":"microee","title":"MicroEE: A Tiny EventEmitter Implementation","description":"MicroEE is an extremely lightweight, EventEmitter-like library designed for both client and server-side event routing. At approximately 50 lines of code and ~1200 characters, it was created to be significantly smaller than other event emitter implementations of its time. The package's current stable version is 0.0.6, which was published nearly a decade ago, indicating it is no longer actively maintained. Its primary differentiators were its minimal footprint and a simple API largely based on Node.js's native EventEmitter, with additions like `emitter.when()` for conditional listener removal and `microee.mixin()` for easily extending objects to become event emitters. It lacks modern features like `async` event handling or native ES module support.","language":"javascript","status":"abandoned","last_verified":"Tue Apr 21","install":{"commands":["npm install microee"],"cli":null},"imports":["const MicroEE = require('microee');","const MicroEE = require('microee'); MicroEE.mixin(MyClass);","const obj = new MyClass(); obj.on('event', listener);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const MicroEE = require('microee');\n\nfunction MyClass() {\n  // Constructor logic\n}\nMicroEE.mixin(MyClass);\n\nMyClass.prototype.foo = function() {\n  console.log('foo method called');\n  this.emit('fooCalled', 'data from foo');\n};\n\nconst obj = new MyClass();\n\n// Add a listener for 'event'\nobj.on('event', function(arg1, arg2) {\n  console.log(`'event' fired with args: ${arg1}, ${arg2}`);\n});\n\n// Add a one-time listener for 'onceEvent'\nobj.once('onceEvent', function() {\n  console.log(\"'onceEvent' fired - this will only happen once.\");\n});\n\n// Add a listener that removes itself conditionally\nlet counter = 0;\nobj.when('conditionalEvent', function() {\n  counter++;\n  console.log(`'conditionalEvent' fired, counter: ${counter}`);\n  return counter >= 2; // Remove listener after 2 fires\n});\n\n// Emit events\nobj.emit('event', 'hello', 'world'); // Triggers 'event' listener\nobj.emit('onceEvent');             // Triggers 'onceEvent' listener once\nobj.emit('onceEvent');             // Does nothing now\nobj.emit('conditionalEvent');      // Triggers 'conditionalEvent' (counter 1)\nobj.emit('conditionalEvent');      // Triggers 'conditionalEvent' (counter 2) and removes itself\nobj.emit('conditionalEvent');      // Does nothing now\n\nobj.foo(); // Calls foo, which emits 'fooCalled'\nobj.on('fooCalled', (data) => console.log(`'fooCalled' received: ${data}`));\nobj.foo();","lang":"javascript","description":"Demonstrates how to use `microee.mixin` to make a class an event emitter, along with basic `on`, `emit`, `once`, and `when` methods.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}