News for hackers. Stuff that matters.
Re:Better-Mitt: A tiny (~400B) TypeScript-first event emitte... by dhax_or on Monday May 26, 2025 @04:52AM (#44095391)
I built this as an improved version of the popular Mitt library. It keeps the tiny footprint (~400 bytes gzipped) while adding genuinely useful features that I found myself needing in real projects:

- once() for one-time listeners - hasListeners() and listenerCount() for introspection - clear() to reset everything - Safer emission that protects against handler modification during events - Full TypeScript support with generic types

Same familiar API as Node's EventEmitter and original Mitt, so it's a drop-in replacement. I've been using it in production and it's been solid.

GitHub: https://github.com/Dhaxor/better-mitt

NPM: npm install better-mitt

Would love feedback from the community - and if you find it useful, a GitHub star would be much appreciated!

Re:Better-Mitt: A tiny (~400B) TypeScript-first event emitte... by softwarefef on Monday May 26, 2025 @06:35AM (#44095988)
I guess the increase in bytes was because of the added functionalities?
Re:Better-Mitt: A tiny (~400B) TypeScript-first event emitte... by nakamurahiro1 on Monday May 26, 2025 @06:12AM (#44095849)
Great work! I've always wanted a once in an event emitter but mitt never had that