{"id":16123,"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.","status":"abandoned","version":"0.0.6","language":"javascript","source_language":"en","source_url":"git://github.com/mixu/microee","tags":["javascript","event","events","eventemitter","emitter"],"install":[{"cmd":"npm install microee","lang":"bash","label":"npm"},{"cmd":"yarn add microee","lang":"bash","label":"yarn"},{"cmd":"pnpm add microee","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and does not support ES modules natively. It also exports a global `microee` in browser environments.","wrong":"import { MicroEE } from 'microee';","symbol":"MicroEE","correct":"const MicroEE = require('microee');"},{"note":"The `mixin` utility is a static method on the MicroEE constructor, used to extend a class prototype. It is not a named export.","wrong":"import { mixin } from 'microee';","symbol":"mixin","correct":"const MicroEE = require('microee'); MicroEE.mixin(MyClass);"},{"note":"Methods like `on`, `emit`, `once` are prototypal methods after applying `MicroEE.mixin` or instantiating MicroEE directly.","symbol":"emitter.on","correct":"const obj = new MyClass(); obj.on('event', listener);"}],"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."},"warnings":[{"fix":"Use exact string event names. If dynamic event matching is required, implement custom logic or use a different library.","message":"This package explicitly does not support RegExp matching for event names, unlike some other EventEmitter implementations. Event names must be exact strings.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Migrate to a actively maintained event emitter library such as Node.js's built-in `EventEmitter` (if in Node.js) or a modern standalone package like `eventemitter3` or `mitt`.","message":"The `microee` package is abandoned. The last release (v0.0.6) was published 9 years ago, and there is no ongoing maintenance or development. It is not recommended for new projects.","severity":"deprecated","affected_versions":">=0.0.1"},{"fix":"If using in a modern ES module environment, you might need a CommonJS compatibility layer or bundler configuration to consume it, or simply use `require()` if your environment supports it. Prefer a modern alternative for ESM projects.","message":"The package is CommonJS-only and relies on `require()` for Node.js or a global `microee` object in browsers. It does not provide native ES module (`import`) support.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure you are using `const MicroEE = require('microee');` in Node.js or confirming the `microee` global is available in your browser context. If using ES modules, you must configure your bundler to handle CommonJS modules or use a different library.","cause":"Attempting to use `MicroEE` without correctly importing/requiring it in a CommonJS or browser environment, or trying to use `import` syntax.","error":"ReferenceError: MicroEE is not defined"},{"fix":"Before calling `on` or `emit` methods, ensure your class or object's prototype has been extended with `MicroEE.mixin(MyClass)` for class-based usage, or that you are using an instance created by `new MicroEE()` directly.","cause":"An object intended to be an event emitter has not had the `MicroEE.mixin` applied to its prototype or is not an instance of a class that has applied the mixin.","error":"TypeError: obj.on is not a function"}],"ecosystem":"npm"}